]> code.citadel.org Git - citadel.git/commitdiff
* Still trying to fix a socket connect bug
authorArt Cancro <ajc@citadel.org>
Thu, 31 Aug 2000 21:32:44 +0000 (21:32 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 31 Aug 2000 21:32:44 +0000 (21:32 +0000)
citadel/ChangeLog
citadel/dynloader.c
citadel/serv_imap.c
citadel/serv_pop3.c
citadel/sysdep.c

index f0a198492e7ed71d5813fd2adb9d50007fb25dcd..3f4b48903ee8be7a838d84f540e8d54c69596ccb 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 572.32  2000/08/31 21:32:44  ajc
+ * Still trying to fix a socket connect bug
+
  Revision 572.31  2000/08/31 16:37:08  ajc
  * docs/import-export.txt: added.
 
@@ -2011,3 +2014,4 @@ 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 de01715ebfba83ea3f03155c1adff9dc0b6f0ed6..ae2e402e69f64ca6bb0c13fdd54e1b379ef3d492 100644 (file)
@@ -238,6 +238,7 @@ void CtdlRegisterServiceHook(int tcp_port,
                        void (*h_command_function) (void) )
 {
        struct ServiceFunctionHook *newfcn;
+       char message[256];
 
        newfcn = (struct ServiceFunctionHook *)
            mallok(sizeof(struct ServiceFunctionHook));
@@ -249,24 +250,26 @@ void CtdlRegisterServiceHook(int tcp_port,
 
        if (sockpath != NULL) {
                newfcn->msock = ig_uds_server(sockpath, config.c_maxsessions);
+               sprintf(message, "Unix domain socket %s: ", sockpath);
        }
-       else if (tcp_port < 0) {        /* port -1 to disable */
+       else if (tcp_port <= 0) {       /* port -1 to disable */
                lprintf(7, "Service has been manually disabled, skipping\n");
                phree(newfcn);
                return;
        }
        else {
                newfcn->msock = ig_tcp_server(tcp_port, config.c_maxsessions);
+               sprintf(message, "TCP port %d: ", tcp_port);
        }
 
-       if (newfcn->msock >= 0) {
+       if (newfcn->msock > 0) {
                ServiceHookTable = newfcn;
-               lprintf(5, "Registered a new service (TCP port %d)\n",
-                       tcp_port);
+               strcat(message, "registered.");
+               lprintf(5, "%s\n", message);
        }
        else {
-               lprintf(2, "ERROR: could not bind to TCP port %d.\n",
-                       tcp_port);
+               strcat(message, "FAILED.");
+               lprintf(2, "%s\n", message);
                phree(newfcn);
        }
 }
index a43bb4b63044bf6b80490e48d87a4fa855198d45..a831b7c3ef0a4107750b98a3dfd90e648bcc1a7d 100644 (file)
@@ -283,7 +283,7 @@ void imap_command_loop(void) {
 char *Dynamic_Module_Init(void)
 {
        SYM_IMAP = CtdlGetDynamicSymbol();
-       CtdlRegisterServiceHook(0,      /* FIXME put in config setup */
+       CtdlRegisterServiceHook(-1,     /* FIXME put in config setup */
                                NULL,
                                imap_greeting,
                                imap_command_loop);
index 9ba67f9f6eb541b5ae1589750f110c58f824e251..b8273f89716aa1d7599fcb41f3883a1e40922add 100644 (file)
@@ -608,7 +608,6 @@ void pop3_command_loop(void) {
 char *Dynamic_Module_Init(void)
 {
        SYM_POP3 = CtdlGetDynamicSymbol();
-       printf("Registering POP3 port %d\n", config.c_pop3_port);
        CtdlRegisterServiceHook(config.c_pop3_port,
                                NULL,
                                pop3_greeting,
index e98e6cf7e24ef794e2c852c0bf1111a775b4c48e..4331e11eca7170a3e0752792082bdd19b70cd40d 100644 (file)
@@ -311,8 +311,14 @@ int ig_uds_server(char *sockpath, int queue_len)
 {
        struct sockaddr_un addr;
        int s;
+       int i;
 
-       unlink(sockpath);
+       i = unlink(sockpath);
+       if (i != 0) if (errno != ENOENT) {
+               lprintf(1, "citserver: can't unlink %s: %s\n",
+                       sockpath, strerror(errno));
+               return(-1);
+       }
 
        memset(&addr, 0, sizeof(addr));
        addr.sun_family = AF_UNIX;
@@ -782,6 +788,39 @@ void InitializeMasterCC(void) {
 
 
 
+/*
+ * Set up a fd_set containing all the master sockets to which we
+ * always listen.  It's computationally less expensive to just copy
+ * this to a local fd_set when starting a new select() and then add
+ * the client sockets than it is to initialize a new one and then
+ * figure out what to put there.
+ */
+void init_master_fdset(void) {
+       struct ServiceFunctionHook *serviceptr;
+       int m;
+
+       lprintf(9, "Initializing master fdset\n");
+
+       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];
+
+       for (serviceptr = ServiceHookTable; serviceptr != NULL;
+           serviceptr = serviceptr->next ) {
+               m = serviceptr->msock;
+               lprintf(9, "Will listen on master socket %d\n", m);
+               FD_SET(m, &masterfds);
+               if (m > masterhighest) {
+                       masterhighest = m;
+               }
+       }
+       lprintf(9, "masterhighest = %d\n", masterhighest);
+}
+
+
+
 /*
  * Here's where it all begins.
  */
@@ -794,7 +833,6 @@ int main(int argc, char **argv)
        struct passwd *pw;
        int drop_root_perms = 1;
        char *moddir;
-       struct ServiceFunctionHook *serviceptr;
         
        /* specify default port name and trace file */
        strcpy(tracefile, "");
@@ -905,28 +943,7 @@ int main(int argc, char **argv)
                exit(errno);
        }
 
-       /*
-        * Set up a fd_set containing all the master sockets to which we
-        * always listen.  It's computationally less expensive to just copy
-        * this to a local fd_set when starting a new select() and then add
-        * the client sockets than it is to initialize a new one and then
-        * figure out what to put there.
-        */
-       FD_ZERO(&masterfds);
-       masterhighest = 0;
-       FD_SET(rescan[0], &masterfds);
-       if (rescan[0] > masterhighest) masterhighest = rescan[0];
-
-       for (serviceptr = ServiceHookTable; serviceptr != NULL;
-           serviceptr = serviceptr->next ) {
-               lprintf(9, "Will listen on master socket %d\n",
-                       serviceptr->msock);
-               FD_SET(serviceptr->msock, &masterfds);
-               if (serviceptr->msock > masterhighest) {
-                       masterhighest = serviceptr->msock;
-               }
-       }
-
+       init_master_fdset();
 
        /*
         * Now that we've bound the sockets, change to the BBS user id and its