summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-01-23 16:42:31 +0100
committerVolker Lendecke <vl@samba.org>2008-01-23 17:09:10 +0100
commita925a53f61ebdc6b4386b7c0853f2f87cbe2e166 (patch)
tree115ee6eb8c3ad08b2ef877ccda6cac49d351374c
parent587cf54c61c9f1f7bcae431a82035fd942716c32 (diff)
downloadsamba-a925a53f61ebdc6b4386b7c0853f2f87cbe2e166.tar.gz
samba-a925a53f61ebdc6b4386b7c0853f2f87cbe2e166.tar.bz2
samba-a925a53f61ebdc6b4386b7c0853f2f87cbe2e166.zip
read_socket_with_timeout has timeout=0 handling
(This used to be commit 7101026061c470ed962267b43ac0aa67cc761a64)
-rw-r--r--source3/lib/util_sock.c39
-rw-r--r--source3/libsmb/clientgen.c8
-rw-r--r--source3/smbd/process.c29
3 files changed, 9 insertions, 67 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index a3975f6c1f..fb8f41513b 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -1054,44 +1054,7 @@ ssize_t read_socket_with_timeout(int fd,
ssize_t read_data(int fd,char *buffer,size_t N, enum smb_read_errors *pre)
{
- ssize_t ret;
- size_t total=0;
- char addr[INET6_ADDRSTRLEN];
-
- set_smb_read_error(pre,SMB_READ_OK);
-
- while (total < N) {
- ret = sys_read(fd,buffer + total,N - total);
-
- if (ret == 0) {
- DEBUG(10,("read_data: read of %d returned 0. "
- "Error = %s\n",
- (int)(N - total), strerror(errno) ));
- set_smb_read_error(pre,SMB_READ_EOF);
- return 0;
- }
-
- if (ret == -1) {
- if (fd == get_client_fd()) {
- /* Try and give an error message saying
- * what client failed. */
- DEBUG(0,("read_data: read failure for %d "
- "bytes to client %s. Error = %s\n",
- (int)(N - total),
- get_peer_addr(fd,addr,sizeof(addr)),
- strerror(errno) ));
- } else {
- DEBUG(0,("read_data: read failure for %d. "
- "Error = %s\n",
- (int)(N - total),
- strerror(errno) ));
- }
- set_smb_read_error(pre,SMB_READ_ERROR);
- return -1;
- }
- total += ret;
- }
- return (ssize_t)total;
+ return read_socket_with_timeout(fd, buffer, N, N, 0, pre);
}
/****************************************************************************
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index ecef293d07..042b3bdfb0 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -180,12 +180,8 @@ bool cli_receive_smb(struct cli_state *cli)
ssize_t cli_receive_smb_data(struct cli_state *cli, char *buffer, size_t len)
{
- if (cli->timeout > 0) {
- return read_socket_with_timeout(cli->fd, buffer, len,
- len, cli->timeout, &cli->smb_rw_error);
- } else {
- return read_data(cli->fd, buffer, len, &cli->smb_rw_error);
- }
+ return read_socket_with_timeout(cli->fd, buffer, len, len,
+ cli->timeout, &cli->smb_rw_error);
}
/****************************************************************************
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 6fd4d17d88..d961f98cc0 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -155,16 +155,8 @@ static ssize_t read_packet_remainder(int fd,
return len;
}
- if (timeout > 0) {
- ret = read_socket_with_timeout(fd,
- buffer,
- len,
- len,
- timeout,
- get_srv_read_error());
- } else {
- ret = read_data(fd, buffer, len, get_srv_read_error());
- }
+ ret = read_socket_with_timeout(fd, buffer, len, len, timeout,
+ get_srv_read_error());
if (ret != len) {
cond_set_smb_read_error(get_srv_read_error(),
@@ -206,19 +198,10 @@ static ssize_t receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx,
memcpy(writeX_header, lenbuf, sizeof(lenbuf));
- if (timeout > 0) {
- ret = read_socket_with_timeout(fd,
- writeX_header + 4,
- STANDARD_WRITE_AND_X_HEADER_SIZE,
- STANDARD_WRITE_AND_X_HEADER_SIZE,
- timeout,
- get_srv_read_error());
- } else {
- ret = read_data(fd,
- writeX_header+4,
- STANDARD_WRITE_AND_X_HEADER_SIZE,
- get_srv_read_error());
- }
+ ret = read_socket_with_timeout(fd, writeX_header + 4,
+ STANDARD_WRITE_AND_X_HEADER_SIZE,
+ STANDARD_WRITE_AND_X_HEADER_SIZE,
+ timeout, get_srv_read_error());
if (ret != STANDARD_WRITE_AND_X_HEADER_SIZE) {
cond_set_smb_read_error(get_srv_read_error(),