summaryrefslogtreecommitdiff
path: root/source3/lib/util_sock.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-01-25 23:41:48 +0100
committerVolker Lendecke <vl@samba.org>2008-02-02 11:03:22 +0100
commit5e43eeb1b6eef7ea7a88ffc51a0a0535e9bd8023 (patch)
tree89fafb0e619e518499d7ff0f7ab8078e509f8628 /source3/lib/util_sock.c
parente514cd0af56031cd0396e716e9e77edf897420e9 (diff)
downloadsamba-5e43eeb1b6eef7ea7a88ffc51a0a0535e9bd8023.tar.gz
samba-5e43eeb1b6eef7ea7a88ffc51a0a0535e9bd8023.tar.bz2
samba-5e43eeb1b6eef7ea7a88ffc51a0a0535e9bd8023.zip
Get rid of read_socket_with_timeout
(This used to be commit f9c8ac83ff42137d2101d3bb17e5dcc3c3d70a8f)
Diffstat (limited to 'source3/lib/util_sock.c')
-rw-r--r--source3/lib/util_sock.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 32dd2bd8a8..d0d321ee39 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -1042,21 +1042,20 @@ NTSTATUS read_socket_with_timeout_ntstatus(int fd, char *buf,
return NT_STATUS_OK;
}
-ssize_t read_socket_with_timeout(int fd, char *buf,
- size_t mincnt, size_t maxcnt,
- unsigned int time_out,
- enum smb_read_errors *pre)
+/****************************************************************************
+ Read data from the client, reading exactly N bytes.
+****************************************************************************/
+
+ssize_t read_data(int fd,char *buffer,size_t N, enum smb_read_errors *pre)
{
NTSTATUS status;
- size_t size_ret;
set_smb_read_error(pre, SMB_READ_OK);
- status = read_socket_with_timeout_ntstatus(fd, buf, mincnt, maxcnt,
- time_out, &size_ret);
+ status = read_socket_with_timeout_ntstatus(fd, buffer, N, N, 0, NULL);
if (NT_STATUS_IS_OK(status)) {
- return size_ret;
+ return N;
}
if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
@@ -1074,15 +1073,6 @@ ssize_t read_socket_with_timeout(int fd, char *buf,
}
/****************************************************************************
- Read data from the client, reading exactly N bytes.
-****************************************************************************/
-
-ssize_t read_data(int fd,char *buffer,size_t N, enum smb_read_errors *pre)
-{
- return read_socket_with_timeout(fd, buffer, N, N, 0, pre);
-}
-
-/****************************************************************************
Write data to a fd.
****************************************************************************/
@@ -1214,7 +1204,6 @@ ssize_t receive_smb_raw(int fd,
enum smb_read_errors *pre)
{
size_t len;
- ssize_t ret;
NTSTATUS status;
set_smb_read_error(pre,SMB_READ_OK);
@@ -1264,11 +1253,23 @@ ssize_t receive_smb_raw(int fd,
len = MIN(len,maxlen);
}
- ret = read_socket_with_timeout(fd, buffer+4, len, len, timeout,
- pre);
+ set_smb_read_error(pre, SMB_READ_OK);
- if (ret != len) {
- cond_set_smb_read_error(pre,SMB_READ_ERROR);
+ status = read_socket_with_timeout_ntstatus(
+ fd, buffer+4, len, len, timeout, &len);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
+ set_smb_read_error(pre, SMB_READ_EOF);
+ return -1;
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
+ set_smb_read_error(pre, SMB_READ_TIMEOUT);
+ return -1;
+ }
+
+ set_smb_read_error(pre, SMB_READ_ERROR);
return -1;
}