[SCM] Samba Shared Repository - branch master updated

David Disseldorp ddiss at samba.org
Fri Mar 20 06:49:03 MDT 2015


The branch, master has been updated
       via  4f4151e s3: lib: libsmbclient: If reusing a server struct, check every cli->timout miliseconds if it's still valid before use.
      from  00d92f5 s3: libcli: smb1: Ensure we correctly finish a tevent req if the writev fails in the SMB1 case.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4f4151ea050a5f34e42d73a4bf9448c673a35787
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Mar 18 14:15:16 2015 -0700

    s3: lib: libsmbclient: If reusing a server struct, check every cli->timout miliseconds if it's still valid before use.
    
    Uses an cli_echo() call to do so.
    
    Based on code from <shargagan at novell.com>
    
    Bug 11079 - libsmbclient not checking the cached connection alive status before re-using it from connection cache
    
    https://bugzilla.samba.org/show_bug.cgi?id=11079
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    
    Autobuild-User(master): David Disseldorp <ddiss at samba.org>
    Autobuild-Date(master): Fri Mar 20 13:48:26 CET 2015 on sn-devel-104

-----------------------------------------------------------------------

Summary of changes:
 source3/include/libsmb_internal.h |  1 +
 source3/libsmb/libsmb_server.c    | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)


Changeset truncated at 500 lines:

diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h
index ce73181..65fad99 100644
--- a/source3/include/libsmb_internal.h
+++ b/source3/include/libsmb_internal.h
@@ -81,6 +81,7 @@ struct _SMBCSRV {
 	bool no_pathinfo3;
         bool no_nt_session;
         struct policy_handle pol;
+	time_t last_echo_time;
 
 	SMBCSRV *next, *prev;
 };
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index 8f68a40..d6c2588 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -45,10 +45,26 @@ int
 SMBC_check_server(SMBCCTX * context,
                   SMBCSRV * server)
 {
+	time_t now;
+
 	if (!cli_state_is_connected(server->cli)) {
 		return 1;
 	}
 
+	now = time_mono(NULL);
+
+	if (server->last_echo_time == (time_t)0 ||
+			now > server->last_echo_time +
+				(server->cli->timeout/1000)) {
+		unsigned char data[16] = {0};
+		NTSTATUS status = cli_echo(server->cli,
+					1,
+					data_blob_const(data, sizeof(data)));
+		if (!NT_STATUS_IS_OK(status)) {
+			return 1;
+		}
+		server->last_echo_time = now;
+	}
 	return 0;
 }
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list