]> code.citadel.org Git - citadel.git/commitdiff
* ig_tcp_server() and ig_uds_server() - check to make sure queue length is
authorArt Cancro <ajc@citadel.org>
Thu, 31 Aug 2000 23:02:15 +0000 (23:02 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 31 Aug 2000 23:02:15 +0000 (23:02 +0000)
  always at least 5.  Zero-length queues can cause connection lockups.

citadel/ChangeLog
citadel/dynloader.c
citadel/sysdep.c

index 3f4b48903ee8be7a838d84f540e8d54c69596ccb..e6365488f91f29c3e1c7fff70f68650472d5efa0 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 572.33  2000/08/31 23:02:15  ajc
+ * ig_tcp_server() and ig_uds_server()  -  check to make sure queue length is
+   always at least 5.  Zero-length queues can cause connection lockups.
+
  Revision 572.32  2000/08/31 21:32:44  ajc
  * Still trying to fix a socket connect bug
 
@@ -2014,4 +2018,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
-
index ae2e402e69f64ca6bb0c13fdd54e1b379ef3d492..459d6d62731e046576483c20cf6df69f7226d40f 100644 (file)
@@ -18,7 +18,7 @@
 #endif
 #include <sys/types.h>
 #include <dirent.h>
-#include <strings.h>
+#include <string.h>
 #include <syslog.h>
 #include <limits.h>
 #include <ctype.h>
@@ -250,7 +250,7 @@ void CtdlRegisterServiceHook(int tcp_port,
 
        if (sockpath != NULL) {
                newfcn->msock = ig_uds_server(sockpath, config.c_maxsessions);
-               sprintf(message, "Unix domain socket %s: ", sockpath);
+               sprintf(message, "Unix domain socket '%s': ", sockpath);
        }
        else if (tcp_port <= 0) {       /* port -1 to disable */
                lprintf(7, "Service has been manually disabled, skipping\n");
index 4331e11eca7170a3e0752792082bdd19b70cd40d..083e3550ea7763076a3853d418aefb8ded7cfb27 100644 (file)
@@ -268,6 +268,10 @@ int ig_tcp_server(int port_number, int queue_len)
 {
        struct sockaddr_in sin;
        int s, i;
+       int actual_queue_len;
+
+       actual_queue_len = queue_len;
+       if (actual_queue_len < 5) actual_queue_len = 5;
 
        memset(&sin, 0, sizeof(sin));
        sin.sin_family = AF_INET;
@@ -293,7 +297,7 @@ int ig_tcp_server(int port_number, int queue_len)
                return(-1);
        }
 
-       if (listen(s, queue_len) < 0) {
+       if (listen(s, actual_queue_len) < 0) {
                lprintf(1, "citserver: Can't listen: %s\n", strerror(errno));
                close(s);
                return(-1);
@@ -312,6 +316,10 @@ int ig_uds_server(char *sockpath, int queue_len)
        struct sockaddr_un addr;
        int s;
        int i;
+       int actual_queue_len;
+
+       actual_queue_len = queue_len;
+       if (actual_queue_len < 5) actual_queue_len = 5;
 
        i = unlink(sockpath);
        if (i != 0) if (errno != ENOENT) {
@@ -337,7 +345,7 @@ int ig_uds_server(char *sockpath, int queue_len)
                return(-1);
        }
 
-       if (listen(s, queue_len) < 0) {
+       if (listen(s, actual_queue_len) < 0) {
                lprintf(1, "citserver: Can't listen: %s\n", strerror(errno));
                return(-1);
        }
@@ -803,6 +811,7 @@ void init_master_fdset(void) {
 
        FD_ZERO(&masterfds);
        masterhighest = 0;
+
        lprintf(9, "Will listen on rescan pipe %d\n", rescan[0]);
        FD_SET(rescan[0], &masterfds);
        if (rescan[0] > masterhighest) masterhighest = rescan[0];
@@ -911,13 +920,17 @@ int main(int argc, char **argv)
        master_startup();
 
        /*
-        * Bind the server to our favorite ports.
+        * Bind the server to a Unix-domain socket.
         */
-       CtdlRegisterServiceHook(0,                              /* Unix */
+       CtdlRegisterServiceHook(0,
                                "citadel.socket",
                                citproto_begin_session,
                                do_command_loop);
-       CtdlRegisterServiceHook(config.c_port_number,           /* TCP */
+
+       /*
+        * Bind the server to our favorite TCP port (usually 504).
+        */
+       CtdlRegisterServiceHook(config.c_port_number,
                                NULL,
                                citproto_begin_session,
                                do_command_loop);
@@ -1041,7 +1054,7 @@ void worker_thread(void) {
                 */
 
                begin_critical_section(S_I_WANNA_SELECT);
-SETUP_FD:      memcpy(&readfds, &masterfds, sizeof(fd_set) );
+SETUP_FD:      memcpy(&readfds, &masterfds, sizeof masterfds);
                highest = masterhighest;
                begin_critical_section(S_SESSION_TABLE);
                for (ptr = ContextList; ptr != NULL; ptr = ptr->next) {