diff options
author | Jeremy Allison <jra@samba.org> | 2005-06-15 00:22:59 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:57:15 -0500 |
commit | 2efcdb2fb8202952df3337c3dde9617b9bb096f4 (patch) | |
tree | 3842bd00b0386be1c8d17b6d0acd088da8b19ab0 /source3 | |
parent | 95915107210a756e32a4b1a443659ba787b954e1 (diff) | |
download | samba-2efcdb2fb8202952df3337c3dde9617b9bb096f4.tar.gz samba-2efcdb2fb8202952df3337c3dde9617b9bb096f4.tar.bz2 samba-2efcdb2fb8202952df3337c3dde9617b9bb096f4.zip |
r7591: Don't call getpeeraddr on a disconnected socket.
Jeremy.
(This used to be commit a9cd218eb607066a65818b534ec5e3ecb55da4cf)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/util_sock.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index e5e16f1c48..6562dae952 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -26,10 +26,13 @@ some generic functions to get info that really should be hidden in particular modules */ static int client_fd = -1; +/* What to print out on a client disconnect error. */ +static char client_ip_string[16]; void client_setfd(int fd) { client_fd = fd; + safe_strcpy(client_ip_string, get_peer_addr(client_fd), sizeof(client_ip_string)-1); } static char *get_socket_addr(int fd) @@ -418,7 +421,7 @@ ssize_t read_socket_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,un if (fd == client_fd) { /* Try and give an error message saying what client failed. */ DEBUG(0,("read_socket_with_timeout: client %s read error = %s.\n", - client_addr(), strerror(errno) )); + client_ip_string, strerror(errno) )); } else { DEBUG(0,("read_socket_with_timeout: read error = %s.\n", strerror(errno) )); } @@ -452,7 +455,7 @@ ssize_t read_socket_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,un if (fd == client_fd) { /* Try and give an error message saying what client failed. */ DEBUG(0,("read_socket_with_timeout: timeout read for client %s. select error = %s.\n", - client_addr(), strerror(errno) )); + client_ip_string, strerror(errno) )); } else { DEBUG(0,("read_socket_with_timeout: timeout read. select error = %s.\n", strerror(errno) )); } @@ -481,7 +484,7 @@ ssize_t read_socket_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,un if (fd == client_fd) { /* Try and give an error message saying what client failed. */ DEBUG(0,("read_socket_with_timeout: timeout read to client %s. read error = %s.\n", - client_addr(), strerror(errno) )); + client_ip_string, strerror(errno) )); } else { DEBUG(0,("read_socket_with_timeout: timeout read. read error = %s.\n", strerror(errno) )); } @@ -520,7 +523,7 @@ ssize_t read_data(int fd,char *buffer,size_t N) if (fd == 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), client_addr(), strerror(errno) )); + (int)(N - total), client_ip_string, strerror(errno) )); } else { DEBUG(0,("read_data: read failure for %d. Error = %s\n", (int)(N - total), strerror(errno) )); } @@ -548,7 +551,7 @@ ssize_t write_data(int fd, const char *buffer, size_t N) if (fd == client_fd) { /* Try and give an error message saying what client failed. */ DEBUG(0,("write_data: write failure in writing to client %s. Error %s\n", - client_addr(), strerror(errno) )); + client_ip_string, strerror(errno) )); } else { DEBUG(0,("write_data: write failure. Error = %s\n", strerror(errno) )); } |