]> code.citadel.org Git - citadel.git/commitdiff
In r3487 we had set the master listening sockets to
authorArt Cancro <ajc@citadel.org>
Tue, 4 Apr 2006 18:29:19 +0000 (18:29 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 4 Apr 2006 18:29:19 +0000 (18:29 +0000)
non-blocking in order to avoid locking up the server when select() returns
but accept() does not.  This sets the individual connection sockets to non
blocking as well.  Now, the individual sockets are set back to blocking mode.
This prevents certain network operations from barfing when running on
FreeBSD.

citadel/sysdep.c

index 4022555a4ca72d43218cdffeea5e68655d57c7e2..33fde1e5157cf9106575fa8cfbef3fd64d6a1c53 100644 (file)
@@ -1051,19 +1051,29 @@ do_select:      force_purge = 0;
                                                "New client socket %d\n",
                                                ssock);
 
+                                       /* The master socket is non-blocking but the client
+                                        * sockets need to be blocking, otherwise certain
+                                        * operations barf on FreeBSD.  Not a fatal error.
+                                        */
+                                       if (fcntl(ssock, F_SETFL, 0) < 0) {
+                                               lprintf(CTDL_EMERG,
+                                                       "citserver: Can't set socket to blocking: %s\n",
+                                                       strerror(errno));
+                                       }
+
                                        /* New context will be created already
-                                       * set up in the CON_EXECUTING state.
-                                       */
+                                        * set up in the CON_EXECUTING state.
+                                        */
                                        con = CreateNewContext();
 
-                                       /* Assign new socket number to it. */
+                                       /* Assign our new socket number to it. */
                                        con->client_socket = ssock;
                                        con->h_command_function =
                                                serviceptr->h_command_function;
                                        con->h_async_function =
                                                serviceptr->h_async_function;
 
-                                       /* Determine whether local socket */
+                                       /* Determine whether it's a local socket */
                                        if (serviceptr->sockpath != NULL)
                                                con->is_local_socket = 1;