summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2019-05-21 01:48:11 +0200
committerGravatar Nikias Bassen2019-05-21 01:48:11 +0200
commit9efb1745bf0eb68064a670b297d4ec7fc98caa02 (patch)
tree35d08bfe8ebde55baefb30e0f009bb31c1e06971 /common
parentcf265a8cf3059b34209cdef8afb3b77246614e68 (diff)
downloadlibusbmuxd-9efb1745bf0eb68064a670b297d4ec7fc98caa02.tar.gz
libusbmuxd-9efb1745bf0eb68064a670b297d4ec7fc98caa02.tar.bz2
socket: Return -ECONNRESET from socket_receive_timeout() instead of -EAGAIN if peer closed the socket
Returning -EAGAIN would indicate the caller can try again, but if the peer closed the socket that wouldn't make any sense. Thanks to sctol for reporting.
Diffstat (limited to 'common')
-rw-r--r--common/socket.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/common/socket.c b/common/socket.c
index 9ff138b..aa97848 100644
--- a/common/socket.c
+++ b/common/socket.c
@@ -49,6 +49,10 @@ static int wsa_init = 0;
#define RECV_TIMEOUT 20000
#define CONNECT_TIMEOUT 5000
+#ifndef ECONNRESET
+#define ECONNRESET 108
+#endif
+
static int verbose = 0;
void socket_set_verbose(int level)
@@ -475,7 +479,7 @@ int socket_receive_timeout(int fd, void *data, size_t length, int flags,
// but this is an error condition
if (verbose >= 3)
fprintf(stderr, "%s: fd=%d recv returned 0\n", __func__, fd);
- return -EAGAIN;
+ return -ECONNRESET;
}
if (result < 0) {
return -errno;