* make the write -1 aware here too.
[citadel.git] / citadel / modules / network / serv_network.c
index e2d16dd9aa08e521799e10ba0cbfa84cdbf15c23..2ac84e3afa3159e38b2be0e2bd6e1d130f6400df 100644 (file)
@@ -1799,7 +1799,7 @@ void receive_spool(int *sock, char *remote_nodename) {
        FILE *fp, *newfp;
 
        CtdlMakeTempFileName(tempfilename, sizeof tempfilename);
-       if (sock_puts(*sock, "NDOP") < 0) return;
+       if (sock_puts(sock, "NDOP") < 0) return;
        if (sock_getln(sock, buf, sizeof buf) < 0) return;
        CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
@@ -1830,7 +1830,7 @@ void receive_spool(int *sock, char *remote_nodename) {
                        bytes_received,
                     ((download_len - bytes_received > IGNET_PACKET_SIZE)
                 ? IGNET_PACKET_SIZE : (download_len - bytes_received)));
-               if (sock_puts(*sock, buf) < 0) {
+               if (sock_puts(sock, buf) < 0) {
                        fclose(fp);
                        unlink(tempfilename);
                        return;
@@ -1859,7 +1859,7 @@ void receive_spool(int *sock, char *remote_nodename) {
                unlink(tempfilename);
                return;
        }
-       if (sock_puts(*sock, "CLOS") < 0) {
+       if (sock_puts(sock, "CLOS") < 0) {
                unlink(tempfilename);
                return;
        }
@@ -1922,7 +1922,7 @@ void transmit_spool(int *sock, char *remote_nodename)
        int fd;
        char sfname[128];
 
-       if (sock_puts(*sock, "NUOP") < 0) return;
+       if (sock_puts(sock, "NUOP") < 0) return;
        if (sock_getln(sock, buf, sizeof buf) < 0) return;
        CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
@@ -1953,7 +1953,7 @@ void transmit_spool(int *sock, char *remote_nodename)
                        }
                        
                        snprintf(buf, sizeof buf, "WRIT %ld", bytes_to_write);
-                       if (sock_puts(*sock, buf) < 0) {
+                       if (sock_puts(sock, buf) < 0) {
                                close(fd);
                                return;
                        }
@@ -1963,7 +1963,7 @@ void transmit_spool(int *sock, char *remote_nodename)
                        }
                        thisblock = atol(&buf[4]);
                        if (buf[0] == '7') {
-                               if (sock_write(*sock, pbuf,
+                               if (sock_write(sock, pbuf,
                                   (int) thisblock) < 0) {
                                        close(fd);
                                        return;
@@ -1982,7 +1982,7 @@ ABORTUPL:
        if(CtdlThreadCheckStop())
                return;
                
-       if (sock_puts(*sock, "UCLS 1") < 0) return;
+       if (sock_puts(sock, "UCLS 1") < 0) return;
        /**
         * From here on we must complete or messages will get lost
         */
@@ -2036,7 +2036,7 @@ void network_poll_node(char *node, char *secret, char *host, char *port) {
                /* We're talking to the correct node.  Now identify ourselves. */
                snprintf(buf, sizeof buf, "NETP %s|%s", config.c_nodename, secret);
                CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
-               if (sock_puts(sock, buf) <0) goto bail;
+               if (sock_puts(&sock, buf) <0) goto bail;
                if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
                CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
                if (buf[0] != '2') goto bail;
@@ -2048,8 +2048,10 @@ void network_poll_node(char *node, char *secret, char *host, char *port) {
                        transmit_spool(&sock, node);
        }
 
-       sock_puts(sock, "QUIT");
-bail:  sock_close(sock);
+       sock_puts(&sock, "QUIT");
+bail:  
+       if (sock != -1)
+               sock_close(sock);
        network_talking_to(node, NTT_REMOVE);
 }