]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/network/serv_network.c
Replaced client_read() with socket_read_blob() in serv_network.c
[citadel.git] / citadel / modules / network / serv_network.c
index 7f5d5dd306e6a172880f9d0c0c63c6201116a69f..075b4578a9616204d3ae5af0497192bc9df386da 100644 (file)
@@ -1924,7 +1924,6 @@ void receive_spool(int *sock, char *remote_nodename) {
        int download_len = 0L;
        int bytes_received = 0L;
        char buf[SIZ];
-       static char pbuf[IGNET_PACKET_SIZE];
        char tempfilename[PATH_MAX];
        char permfilename[PATH_MAX];
        int plen;
@@ -1998,13 +1997,17 @@ void receive_spool(int *sock, char *remote_nodename) {
                
                if (buf[0] == '6') {
                        plen = extract_int(&buf[4], 0);
-                       if (sock_read(sock, pbuf, plen, 1) < 0) {
+                       StrBuf *pbuf = NewStrBuf();
+                       if (socket_read_blob(sock, pbuf, plen, CLIENT_TIMEOUT) != plen) {
+                               CtdlLogPrintf(CTDL_INFO, "Short read from peer; aborting.\n");
                                fclose(fp);
                                unlink(tempfilename);
+                               FreeStrBuf(&pbuf);
                                return;
                        }
-                       fwrite((char *) pbuf, plen, 1, fp);
+                       fwrite(ChrPtr(pbuf), plen, 1, fp);
                        bytes_received += plen;
+                       FreeStrBuf(&pbuf);
                }
        }
 
@@ -2031,7 +2034,6 @@ void receive_spool(int *sock, char *remote_nodename) {
        }
 
        CtdlLogPrintf(CTDL_DEBUG, "%s\n", buf);
-       CtdlLogPrintf(CTDL_NOTICE, "Received %ld octets from <%s>\n", download_len, remote_nodename);
 
        /*
         * Now move the temp file to its permanent location.