Removed a comment documenting the behavior of a bug which we have since fixed.
authorArt Cancro <ajc@uncensored.citadel.org>
Mon, 11 Jul 2011 17:39:44 +0000 (13:39 -0400)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 21:34:22 +0000 (21:34 +0000)
webcit/serv_func.c
webcit/tcp_sockets.c

index 0c89245516b225e459433d0ba970a0ef5863067a..f4db522900a38203e64297925e1586a61dcd12a8 100644 (file)
@@ -204,8 +204,6 @@ int GetConnected (void)
                        return 1;
                }
 
-               /* 2010jun03: every now and then the connection to Citadel dies before this point.  why? */
-
                /*
                 * From what host is our user connecting?  Go with
                 * the host at the other end of the HTTP socket,
index b6953755e439475f101bc4fb836c75a505bb854f..da483deabceab4b9c1f0162169495d69411b738b 100644 (file)
@@ -52,7 +52,7 @@ int uds_connectsock(char *sockpath)
 
        s = socket(AF_UNIX, SOCK_STREAM, 0);
        if (s < 0) {
-               syslog(1, "Can't create socket[%s]: %s\n", sockpath, strerror(errno));
+               syslog(1, "Can't create socket [%s]: %s\n", sockpath, strerror(errno));
                return(-1);
        }
 
@@ -185,6 +185,7 @@ int StrBuf_ServGetln(StrBuf *buf)
                syslog(1, "StrBuf_ServGetln(): Server connection broken: %s\n",
                        (ErrStr)?ErrStr:"");
                wc_backtrace();
+               if (WCC->serv_sock > 0) close(WCC->serv_sock);
                WCC->serv_sock = (-1);
                WCC->connected = 0;
                WCC->logged_in = 0;
@@ -220,6 +221,7 @@ int StrBuf_ServGetBLOBBuffered(StrBuf *buf, long BlobSize)
                syslog(1, "StrBuf_ServGetBLOBBuffered(): Server connection broken: %s\n",
                        (ErrStr)?ErrStr:"");
                wc_backtrace();
+               if (WCC->serv_sock > 0) close(WCC->serv_sock);
                WCC->serv_sock = (-1);
                WCC->connected = 0;
                WCC->logged_in = 0;
@@ -245,6 +247,7 @@ int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize)
                syslog(1, "StrBuf_ServGetBLOB(): Server connection broken: %s\n",
                        (ErrStr)?ErrStr:"");
                wc_backtrace();
+               if (WCC->serv_sock > 0) close(WCC->serv_sock);
                WCC->serv_sock = (-1);
                WCC->connected = 0;
                WCC->logged_in = 0;
@@ -315,7 +318,7 @@ int serv_write(const char *buf, int nbytes)
                        const char *ErrStr = strerror(errno);
                        syslog(1, "serv_write(): Server connection broken: %s\n",
                                (ErrStr)?ErrStr:"");
-                       close(WCC->serv_sock);
+                       if (WCC->serv_sock > 0) close(WCC->serv_sock);
                        WCC->serv_sock = (-1);
                        WCC->connected = 0;
                        WCC->logged_in = 0;
@@ -422,6 +425,7 @@ int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf)
                        if (rc < 0) {
                                syslog(1, "Server connection broken during download\n");
                                wc_backtrace();
+                               if (WCC->serv_sock > 0) close(WCC->serv_sock);
                                WCC->serv_sock = (-1);
                                WCC->connected = 0;
                                WCC->logged_in = 0;
@@ -577,11 +581,13 @@ int webcit_tcp_server(char *ip_addr, int port_number, int queue_len)
 
        if (b < 0) {
                syslog(1, "Can't bind: %s\n", strerror(errno));
+               close(s);
                return (-WC_EXIT_BIND);
        }
 
        if (listen(s, queue_len) < 0) {
                syslog(1, "Can't listen: %s\n", strerror(errno));
+               close(s);
                return (-WC_EXIT_BIND);
        }
        return (s);
@@ -621,14 +627,14 @@ int webcit_uds_server(char *sockpath, int queue_len)
        }
 
        if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-               syslog(1, "webcit: Can't bind: %s\n",
-                       strerror(errno));
+               syslog(1, "webcit: Can't bind: %s\n", strerror(errno));
+               close(s);
                return (-WC_EXIT_BIND);
        }
 
        if (listen(s, actual_queue_len) < 0) {
-               syslog(1, "webcit: Can't listen: %s\n",
-                       strerror(errno));
+               syslog(1, "webcit: Can't listen: %s\n", strerror(errno));
+               close(s);
                return (-WC_EXIT_BIND);
        }