s3:libsmb only log a dead connection if it was not closed
[samba.git] / source3 / libsmb / clientgen.c
index 2c49a8b3f0e8771751a4aef16fc9d387d57139a6..e26c1718d80e1a749e2e7c0cc0ee3a65426d5d2c 100644 (file)
@@ -248,13 +248,18 @@ bool cli_receive_smb(struct cli_state *cli)
 
        /* If the server is not responding, note that now */
        if (len < 0) {
-               char addr[INET6_ADDRSTRLEN];
-
-               print_sockaddr(addr, sizeof(addr), &cli->dest_ss);
-                DEBUG(0, ("Receiving SMB: Server %s stopped responding\n",
-                         addr));
-               close(cli->fd);
-               cli->fd = -1;
+               /*
+                * only log if the connection should still be open and not when
+                * the connection was closed due to a dropped ip message
+                */
+               if (cli->fd != -1) {
+                       char addr[INET6_ADDRSTRLEN];
+                       print_sockaddr(addr, sizeof(addr), &cli->dest_ss);
+                       DEBUG(0, ("Receiving SMB: Server %s stopped responding\n",
+                               addr));
+                       close(cli->fd);
+                       cli->fd = -1;
+               }
                return false;
        }
 
@@ -766,25 +771,6 @@ bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive)
        return ret;
 }
 
-/****************************************************************************
-Send a keepalive packet to the server
-****************************************************************************/
-
-bool cli_send_keepalive(struct cli_state *cli)
-{
-        if (cli->fd == -1) {
-                DEBUG(3, ("cli_send_keepalive: fd == -1\n"));
-                return false;
-        }
-        if (!send_keepalive(cli->fd)) {
-                close(cli->fd);
-                cli->fd = -1;
-                DEBUG(0,("Error sending keepalive packet to client.\n"));
-                return false;
-        }
-        return true;
-}
-
 struct cli_echo_state {
        uint16_t vwv[1];
        DATA_BLOB data;
@@ -973,7 +959,7 @@ NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
                              pnum_bytes, pbytes);
 fail:
         TALLOC_FREE(ev);
-       if (NT_STATUS_IS_OK(status)) {
+       if (NT_STATUS_IS_OK(status) && (result_parent != NULL)) {
                *result_parent = req;
        }
         return status;