]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbclient3: Replacing Echos in the cli status check with TCP status check.
authorFelix Bussmann <feb@sernet.de>
Mon, 18 Mar 2024 14:19:18 +0000 (15:19 +0100)
committerAnoop C S <anoopcs@samba.org>
Wed, 5 Mar 2025 16:21:34 +0000 (16:21 +0000)
Replacing the echoes, which were being sent every 5 seconds by the client for a CLI status check, with a method that checks the status of the file descriptor instead, for a POLLHUP, POLLRDHUP, or a timeout.

Signed-off-by: Felix Bussmann <feb@sernet.de>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Wed Mar  5 16:21:34 UTC 2025 on atb-devel-224

libcli/smb/smbXcli_base.c
source3/client/client.c

index 6b479a781459a58a3634fad9771585c1553279e8..7f275b5999189546bcfbaa9bfeee02f05e3ca0e7 100644 (file)
@@ -474,6 +474,8 @@ struct smbXcli_conn *smbXcli_conn_create(TALLOC_CTX *mem_ctx,
 
 bool smbXcli_conn_is_connected(struct smbXcli_conn *conn)
 {
+       int ret;
+
        if (conn == NULL) {
                return false;
        }
@@ -482,6 +484,11 @@ bool smbXcli_conn_is_connected(struct smbXcli_conn *conn)
                return false;
        }
 
+       ret = samba_socket_poll_or_sock_error(conn->sock_fd);
+       if ( ret < 0) {
+               return false;
+       }
+
        return true;
 }
 
index d1ccc8cb54e5bc01221d10e8945c42d0aa82410d..c15d9a9eb69120adec6dc7c0afc3fe7951100c30 100644 (file)
@@ -6124,42 +6124,11 @@ cleanup:
 
 static bool finished;
 
-/****************************************************************************
- Make sure we swallow keepalives during idle time.
-****************************************************************************/
-
-static void readline_callback(void)
+static void cli_status_check(void)
 {
-       static time_t last_t;
-       struct timespec now;
-       time_t t;
-       NTSTATUS status;
-       unsigned char garbage[16];
-
-       clock_gettime_mono(&now);
-       t = now.tv_sec;
-
-       if (t - last_t < 5)
-               return;
-
-       last_t = t;
-
-       /* Ping the server to keep the connection alive using SMBecho. */
-       memset(garbage, 0xf0, sizeof(garbage));
-       status = cli_echo(cli, 1, data_blob_const(garbage, sizeof(garbage)));
-       if (NT_STATUS_IS_OK(status) ||
-                       NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
-               /*
-                * Even if server returns NT_STATUS_INVALID_PARAMETER
-                * it still responded.
-                * BUG: https://bugzilla.samba.org/show_bug.cgi?id=13007
-                */
-               return;
-       }
-
        if (!cli_state_is_connected(cli)) {
-               DEBUG(0,("SMBecho failed (%s). The connection is "
-                        "disconnected now\n", nt_errstr(status)));
+               DEBUG(0,("SMB echo failed (%s). The connection is "
+                        "disconnected now\n", nt_errstr(NT_STATUS_CONNECTION_DISCONNECTED)));
                finished = true;
                smb_readline_done();
        }
@@ -6192,7 +6161,7 @@ static int process_stdin(void)
                        TALLOC_FREE(frame);
                        break;
                }
-               line = smb_readline(the_prompt, readline_callback, completion_fn);
+               line = smb_readline(the_prompt, cli_status_check, completion_fn);
                if (!line) {
                        TALLOC_FREE(frame);
                        break;