summaryrefslogtreecommitdiff
path: root/source3/libsmb/clientgen.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-03-27 21:55:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:58 -0500
commit0eab4311946c312795ec5c03c25a340ef0bfc624 (patch)
tree47e8e7e5b11a2dd19389102f6959925fb6a29f19 /source3/libsmb/clientgen.c
parent4a66d0e232271968ba96da50274428916a393975 (diff)
downloadsamba-0eab4311946c312795ec5c03c25a340ef0bfc624.tar.gz
samba-0eab4311946c312795ec5c03c25a340ef0bfc624.tar.bz2
samba-0eab4311946c312795ec5c03c25a340ef0bfc624.zip
r21992: Fix keepalive processing when encryption turned on.
Jeremy. (This used to be commit 8f113ad1918dcd2746ec527ceb79a2a7baa1d415)
Diffstat (limited to 'source3/libsmb/clientgen.c')
-rw-r--r--source3/libsmb/clientgen.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index fc88f7f1e2..b3c38f39ae 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -48,13 +48,13 @@ int cli_set_port(struct cli_state *cli, int port)
*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 @@ static BOOL client_receive_smb(struct cli_state *cli)
}
/* 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 @@ static BOOL client_receive_smb(struct cli_state *cli)
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 @@ BOOL cli_receive_smb(struct cli_state *cli)
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 @@ BOOL cli_receive_smb(struct cli_state *cli)
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;