Close the socket and set the file descriptor to -1 if there was a socket
authorTim Potter <tpot@samba.org>
Wed, 14 Nov 2001 05:58:51 +0000 (05:58 +0000)
committerTim Potter <tpot@samba.org>
Wed, 14 Nov 2001 05:58:51 +0000 (05:58 +0000)
error in cli_receive_smb() and cli_send_smb().
(This used to be commit bedd9c821521dad46df50e8b31e4a58bb0a9a604)

source3/libsmb/clientgen.c

index d3623ad94e5687c3f7e6063af3726aba86a3a4a7..133408dff488f9a02a47af880b9e3b4fe1b86780 100644 (file)
@@ -58,6 +58,13 @@ BOOL cli_receive_smb(struct cli_state *cli)
                }
        }
 
+        /* If the server is not responding, note that now */
+
+        if (!ret) {
+                close(cli->fd);
+                cli->fd = -1;
+        }
+
        return ret;
 }
 
@@ -76,6 +83,8 @@ BOOL cli_send_smb(struct cli_state *cli)
        while (nwritten < len) {
                ret = write_socket(cli->fd,cli->outbuf+nwritten,len - nwritten);
                if (ret <= 0) {
+                        close(cli->fd);
+                        cli->fd = -1;
                        DEBUG(0,("Error writing %d bytes to client. %d\n",
                                 (int)len,(int)ret));
                        return False;