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

jra at samba.org jra at samba.org
Tue Mar 27 21:55:44 GMT 2007


Author: jra
Date: 2007-03-27 21:55:43 +0000 (Tue, 27 Mar 2007)
New Revision: 21992

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

Log:
Fix keepalive processing when encryption turned on.
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	2007-03-27 21:13:31 UTC (rev 21991)
+++ branches/SAMBA_3_0/source/client/client.c	2007-03-27 21:55:43 UTC (rev 21992)
@@ -3666,12 +3666,12 @@
 	timeout.tv_usec = 0;
 	sys_select_intr(cli->fd+1,&fds,NULL,NULL,&timeout);
       		
-	/* We deliberately use receive_smb instead of
+	/* We deliberately use cli_receive_smb_return_keepalive instead of
 	   client_receive_smb as we want to receive
 	   session keepalives and then drop them here.
 	*/
 	if (FD_ISSET(cli->fd,&fds)) {
-		if (!receive_smb(cli->fd,cli->inbuf,0)) {
+		if (!cli_receive_smb_return_keepalive(cli)) {
 			DEBUG(0, ("Read from server failed, maybe it closed the "
 				"connection\n"));
 			return;

Modified: branches/SAMBA_3_0/source/libsmb/clientgen.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/clientgen.c	2007-03-27 21:13:31 UTC (rev 21991)
+++ branches/SAMBA_3_0/source/libsmb/clientgen.c	2007-03-27 21:55:43 UTC (rev 21992)
@@ -48,13 +48,13 @@
  *MUST* be of size BUFFER_SIZE+SAFETY_MARGIN.
  The timeout is in milliseconds
 
- This is exactly the same as receive_smb except that it never returns
+ This is exactly the same as receive_smb except that it can be set to never return
  a session keepalive packet (just as receive_smb used to do).
  receive_smb was changed to return keepalives as the oplock processing means this call
  should never go into a blocking read.
 ****************************************************************************/
 
-static BOOL client_receive_smb(struct cli_state *cli)
+static BOOL client_receive_smb(struct cli_state *cli, BOOL eat_keepalives)
 {
 	BOOL ret;
 	int fd = cli->fd;
@@ -71,8 +71,10 @@
 		}
 
 		/* Ignore session keepalive packets. */
-		if(CVAL(buffer,0) != SMBkeepalive)
-			break;
+		if (eat_keepalives && (CVAL(buffer,0) == SMBkeepalive)) {
+			continue;
+		}
+		break;
 	}
 
 	if (cli_encryption_on(cli)) {
@@ -94,7 +96,7 @@
  Recv an smb.
 ****************************************************************************/
 
-BOOL cli_receive_smb(struct cli_state *cli)
+BOOL cli_receive_smb_internal(struct cli_state *cli, BOOL eat_keepalives)
 {
 	BOOL ret;
 
@@ -103,7 +105,7 @@
 		return False; 
 
  again:
-	ret = client_receive_smb(cli);
+	ret = client_receive_smb(cli, eat_keepalives);
 	
 	if (ret) {
 		/* it might be an oplock break request */
@@ -142,6 +144,24 @@
 	return True;
 }
 
+/****************************************************************************
+ Recv an smb - eat keepalives.
+****************************************************************************/
+
+BOOL cli_receive_smb(struct cli_state *cli)
+{
+	return cli_receive_smb_internal(cli, True);
+}
+
+/****************************************************************************
+ Recv an smb - return keepalives.
+****************************************************************************/
+
+BOOL cli_receive_smb_return_keepalive(struct cli_state *cli)
+{
+	return cli_receive_smb_internal(cli, False);
+}
+
 static ssize_t write_socket(int fd, const char *buf, size_t len)
 {
         ssize_t ret=0;



More information about the samba-cvs mailing list