* don't loop endless if the server dissappears in midaction.
authorWilfried Göesgens <willi@citadel.org>
Sat, 21 Feb 2009 14:11:58 +0000 (14:11 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sat, 21 Feb 2009 14:11:58 +0000 (14:11 +0000)
webcit/tcp_sockets.c

index f9c121b6c0057aa7da56faf5c2b7df3073c89909..135819b311e2ea7ce5ddc085ab8ca1fe58fc6cf6 100644 (file)
@@ -124,7 +124,7 @@ inline void _serv_read(char *buf, int bytes, wcsession *WCC)
        int len, rlen;
 
        len = 0;
-       while (len < bytes) {
+       while ((len < bytes) && (WCC->serv_sock != -1)){
                rlen = read(WCC->serv_sock, &buf[len], bytes - len);
                if (rlen < 1) {
                        lprintf(1, "Server connection broken: %s\n",
@@ -164,7 +164,7 @@ int serv_getln(char *strbuf, int bufsize)
                if ((ch != 13) && (ch != 10)) {
                        strbuf[len++] = ch;
                }
-       } while ((ch != 10) && (ch != 0) && (len < (bufsize-1)));
+       } while ((ch != 10) && (ch != 0) && (len < (bufsize-1)) && (WCC->serv_sock != -1));
        strbuf[len] = 0;
 #ifdef SERV_TRACE
        lprintf(9, "%3d>%s\n", WC->serv_sock, strbuf);