aboutsummaryrefslogtreecommitdiff
path: root/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/socket.c b/socket.c
index 48d6b77..ee87a77 100644
--- a/socket.c
+++ b/socket.c
@@ -175,11 +175,24 @@ int soread(struct socket *so)
if (nn < 0 && (errno == EINTR || errno == EAGAIN))
return 0;
else {
+ int err;
+ socklen_t slen = sizeof err;
+
+ err = errno;
+ if (nn == 0) {
+ getsockopt(so->s, SOL_SOCKET, SO_ERROR, &err, &slen);
+ }
+
DEBUG_MISC((dfd,
" --- soread() disconnected, nn = %d, errno = %d-%s\n",
nn, errno, strerror(errno)));
sofcantrcvmore(so);
- tcp_sockclosed(sototcpcb(so));
+
+ if (err == ECONNRESET || err == ENOTCONN || err == EPIPE) {
+ tcp_drop(sototcpcb(so), err);
+ } else {
+ tcp_sockclosed(sototcpcb(so));
+ }
return -1;
}
}