svn commit: samba r11976 - in branches/SAMBA_3_0/source: client libsmb

jra at samba.org jra at samba.org
Wed Nov 30 17:53:21 GMT 2005


Author: jra
Date: 2005-11-30 17:53:21 +0000 (Wed, 30 Nov 2005)
New Revision: 11976

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=11976

Log:
(Slightly modified) Volker fix for #3293. Use SMBecho instead of
chkpath to keep a connection alive.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/client/client.c
   branches/SAMBA_3_0/source/libsmb/clientgen.c


Changeset:
Modified: branches/SAMBA_3_0/source/client/client.c
===================================================================
--- branches/SAMBA_3_0/source/client/client.c	2005-11-30 17:29:33 UTC (rev 11975)
+++ branches/SAMBA_3_0/source/client/client.c	2005-11-30 17:53:21 UTC (rev 11976)
@@ -3088,7 +3088,12 @@
 		goto again;
 	}
       
-	cli_chkpath(cli, "\\");
+	/* Ping the server to keep the connection alive using SMBecho. */
+	{
+		unsigned char garbage[16];
+		memset(garbage, 0xf0, sizeof(garbage));
+		cli_echo(cli, garbage, sizeof(garbage));
+	}
 }
 
 /****************************************************************************

Modified: branches/SAMBA_3_0/source/libsmb/clientgen.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/clientgen.c	2005-11-30 17:29:33 UTC (rev 11975)
+++ branches/SAMBA_3_0/source/libsmb/clientgen.c	2005-11-30 17:53:21 UTC (rev 11976)
@@ -481,6 +481,7 @@
 /****************************************************************************
 Send a keepalive packet to the server
 ****************************************************************************/
+
 BOOL cli_send_keepalive(struct cli_state *cli)
 {
         if (cli->fd == -1) {
@@ -495,3 +496,36 @@
         }
         return True;
 }
+
+/****************************************************************************
+ Send/receive a SMBecho command: ping the server
+****************************************************************************/
+
+BOOL cli_echo(struct cli_state *cli, unsigned char *data, size_t length)
+{
+	char *p;
+
+	SMB_ASSERT(length < 1024);
+
+	memset(cli->outbuf,'\0',smb_size);
+	set_message(cli->outbuf,1,length,True);
+	SCVAL(cli->outbuf,smb_com,SMBecho);
+	SSVAL(cli->outbuf,smb_tid,65535);
+	SSVAL(cli->outbuf,smb_vwv0,1);
+	cli_setup_packet(cli);
+	p = smb_buf(cli->outbuf);
+	memcpy(p, data, length);
+	p += length;
+
+	cli_setup_bcc(cli, p);
+
+	cli_send_smb(cli);
+	if (!cli_receive_smb(cli)) {
+		return False;
+	}
+
+	if (cli_is_error(cli)) {
+		return False;
+	}
+	return True;
+}



More information about the samba-cvs mailing list