r3314: added a option "socket:testnonblock" to the generic socket code. If
[bbaumbach/samba-autobuild/.git] / source4 / lib / socket / socket_unix.c
index 3a3ce5fe8afbd839c25143b8e5d97f8c4760cddd..d160d897ee21ec9cb17cacd2e3b369aa2beef9f2 100644 (file)
@@ -124,8 +124,7 @@ static NTSTATUS unixdom_listen(struct socket_context *sock,
 }
 
 static NTSTATUS unixdom_accept(struct socket_context *sock, 
-                              struct socket_context **new_sock, 
-                              uint32_t flags)
+                              struct socket_context **new_sock)
 {
        struct sockaddr_un cli_addr;
        socklen_t cli_addr_len = sizeof(cli_addr);
@@ -136,6 +135,14 @@ static NTSTATUS unixdom_accept(struct socket_context *sock,
                return unixdom_error(errno);
        }
 
+       if (!(sock->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);
@@ -145,7 +152,7 @@ static NTSTATUS unixdom_accept(struct socket_context *sock,
        /* copy the socket_context */
        (*new_sock)->type               = sock->type;
        (*new_sock)->state              = SOCKET_STATE_SERVER_CONNECTED;
-       (*new_sock)->flags              = flags;
+       (*new_sock)->flags              = sock->flags;
 
        (*new_sock)->fd                 = new_fd;