summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-07-11 13:19:47 +0200
committerStefan Metzmacher <metze@samba.org>2011-07-11 18:18:27 +0200
commit6ec26f0c1a5ac917864078296d6ca89eb65510f9 (patch)
treed3c6e92f122ca78896cf6dd1d1e3182af0aafb10 /source3/client
parenta2e248f27084fd81631dd3dc6614e078d8f99924 (diff)
downloadsamba-6ec26f0c1a5ac917864078296d6ca89eb65510f9.tar.gz
samba-6ec26f0c1a5ac917864078296d6ca89eb65510f9.tar.bz2
samba-6ec26f0c1a5ac917864078296d6ca89eb65510f9.zip
s3:client: simplify readline_callback() to only use cli_echo()
cli_echo() already swallows NBT keepalive messages, so there's no need to filter them in the 'smbclient' layer. metze
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/client.c63
1 files changed, 9 insertions, 54 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 4a5a31ac09..d489ea7eba 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -4911,7 +4911,8 @@ static void readline_callback(void)
static time_t last_t;
struct timespec now;
time_t t;
- int ret, revents;
+ NTSTATUS status;
+ unsigned char garbage[16];
clock_gettime_mono(&now);
t = now.tv_sec;
@@ -4921,60 +4922,14 @@ static void readline_callback(void)
last_t = t;
- again:
-
- if (cli->fd == -1)
- return;
-
- /* We deliberately use receive_smb_raw instead of
- client_receive_smb as we want to receive
- session keepalives and then drop them here.
- */
-
- ret = poll_intr_one_fd(cli->fd, POLLIN|POLLHUP, 0, &revents);
-
- if ((ret > 0) && (revents & (POLLIN|POLLHUP|POLLERR))) {
- char inbuf[CLI_SAMBA_MAX_LARGE_READX_SIZE + LARGE_WRITEX_HDR_SIZE];
- NTSTATUS status;
- size_t len;
-
- status = receive_smb_raw(cli->fd, inbuf, sizeof(inbuf), 0, 0, &len);
-
- if (!NT_STATUS_IS_OK(status)) {
- if (cli->fd != -1) {
- close(cli->fd);
- cli->fd = -1;
- }
-
- DEBUG(0, ("Read from server failed, maybe it closed "
- "the connection: %s\n", nt_errstr(status)));
-
- finished = true;
- smb_readline_done();
- return;
- }
- if(CVAL(inbuf,0) != SMBkeepalive) {
- DEBUG(0, ("Read from server "
- "returned unexpected packet!\n"));
- return;
- }
-
- goto again;
- }
-
/* Ping the server to keep the connection alive using SMBecho. */
- {
- NTSTATUS status;
- unsigned char garbage[16];
- memset(garbage, 0xf0, sizeof(garbage));
- status = cli_echo(cli, 1, data_blob_const(garbage, sizeof(garbage)));
-
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("SMBecho failed. Maybe server has closed "
- "the connection\n"));
- finished = true;
- smb_readline_done();
- }
+ memset(garbage, 0xf0, sizeof(garbage));
+ status = cli_echo(cli, 1, data_blob_const(garbage, sizeof(garbage)));
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("SMBecho failed. Maybe server has closed "
+ "the connection\n"));
+ finished = true;
+ smb_readline_done();
}
}