summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2009-09-05 10:17:48 -0400
committerSimo Sorce <idra@samba.org>2009-09-05 12:49:26 -0400
commitbc081cf0cc41ad8da24cc60c27ab7c7931d60c55 (patch)
tree684b3e88ee132709acf1eb4e4a34a6b7090e1c2f
parent0cfc2f19eff04f4d48ba065563238ae18f2e3f5b (diff)
downloadsamba-bc081cf0cc41ad8da24cc60c27ab7c7931d60c55.tar.gz
samba-bc081cf0cc41ad8da24cc60c27ab7c7931d60c55.tar.bz2
samba-bc081cf0cc41ad8da24cc60c27ab7c7931d60c55.zip
Save and report the correct errno value.
-rw-r--r--source3/lib/util_sock.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index ec88b6046a..638a92d23b 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -555,6 +555,7 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
size_t nread = 0;
struct timeval timeout;
char addr[INET6_ADDRSTRLEN];
+ int save_errno;
/* just checking .... */
if (maxcnt <= 0)
@@ -576,19 +577,20 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
}
if (readret == -1) {
+ save_errno = errno;
if (fd == get_client_fd()) {
/* Try and give an error message
* saying what client failed. */
DEBUG(0,("read_socket_with_timeout: "
"client %s read error = %s.\n",
get_peer_addr(fd,addr,sizeof(addr)),
- strerror(errno) ));
+ strerror(save_errno) ));
} else {
DEBUG(0,("read_socket_with_timeout: "
"read error = %s.\n",
- strerror(errno) ));
+ strerror(save_errno) ));
}
- return map_nt_error_from_unix(errno);
+ return map_nt_error_from_unix(save_errno);
}
nread += readret;
}
@@ -613,6 +615,7 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
/* Check if error */
if (selrtn == -1) {
+ save_errno = errno;
/* something is wrong. Maybe the socket is dead? */
if (fd == get_client_fd()) {
/* Try and give an error message saying
@@ -620,13 +623,13 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
DEBUG(0,("read_socket_with_timeout: timeout "
"read for client %s. select error = %s.\n",
get_peer_addr(fd,addr,sizeof(addr)),
- strerror(errno) ));
+ strerror(save_errno) ));
} else {
DEBUG(0,("read_socket_with_timeout: timeout "
"read. select error = %s.\n",
- strerror(errno) ));
+ strerror(save_errno) ));
}
- return map_nt_error_from_unix(errno);
+ return map_nt_error_from_unix(save_errno);
}
/* Did we timeout ? */
@@ -646,6 +649,7 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
}
if (readret == -1) {
+ save_errno = errno;
/* the descriptor is probably dead */
if (fd == get_client_fd()) {
/* Try and give an error message
@@ -653,11 +657,11 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
DEBUG(0,("read_socket_with_timeout: timeout "
"read to client %s. read error = %s.\n",
get_peer_addr(fd,addr,sizeof(addr)),
- strerror(errno) ));
+ strerror(save_errno) ));
} else {
DEBUG(0,("read_socket_with_timeout: timeout "
"read. read error = %s.\n",
- strerror(errno) ));
+ strerror(save_errno) ));
}
return map_nt_error_from_unix(errno);
}