r3313: in socket_accept() make the new socket non-blocking unless SOCKET_FLAG_BLOCK...
authorAndrew Tridgell <tridge@samba.org>
Thu, 28 Oct 2004 07:34:11 +0000 (07:34 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:04:53 +0000 (13:04 -0500)
(This used to be commit a2d92aa431e0e9752387eebe741d9e6f376f74d7)

source4/lib/socket/socket_ipv4.c
source4/lib/socket/socket_unix.c

index 4de0d8cebee833da8e7c5350d9d9248a28957986..71e1c62235f9c82b2abc8f6f55709b2144916027 100644 (file)
@@ -141,6 +141,14 @@ static NTSTATUS ipv4_tcp_accept(struct socket_context *sock, struct socket_conte
                return map_nt_error_from_unix(errno);
        }
 
+       if (!(flags & SOCKET_FLAG_BLOCK)) {
+               int ret = set_blocking(new_fd, False);
+               if (ret == -1) {
+                       close(new_fd);
+                       return map_nt_error_from_unix(errno);
+               }
+       }
+
        /* TODO: we could add a 'accept_check' hook here
         *       which get the black/white lists via socket_set_accept_filter()
         *       or something like that
index 3a3ce5fe8afbd839c25143b8e5d97f8c4760cddd..239e4eb0694deea61331a04c60d9536295d75e39 100644 (file)
@@ -136,6 +136,14 @@ static NTSTATUS unixdom_accept(struct socket_context *sock,
                return unixdom_error(errno);
        }
 
+       if (!(flags & SOCKET_FLAG_BLOCK)) {
+               int ret = set_blocking(new_fd, False);
+               if (ret == -1) {
+                       close(new_fd);
+                       return map_nt_error_from_unix(errno);
+               }
+       }
+
        (*new_sock) = talloc_p(NULL, struct socket_context);
        if (!(*new_sock)) {
                close(new_fd);