From 46e97b761ccf654120e65f394317adbe49720bcf Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Mon, 19 Sep 2016 10:08:23 +0200 Subject: Don't wait for _writable_ when _reading_ a TCP socket. Like 92a0c39a for TCP. Patch by Fabian Mauchle. --- tcp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tcp.c b/tcp.c index 515acbf..5010bd8 100644 --- a/tcp.c +++ b/tcp.c @@ -135,7 +135,7 @@ int tcpconnect(struct server *server, struct timeval *when, int timeout, char *t /* returns 0 on timeout, -1 on error and num if ok */ int tcpreadtimeout(int s, unsigned char *buf, int num, int timeout) { int ndesc, cnt, len; - fd_set readfds, writefds; + fd_set readfds; struct timeval timer; if (s < 0) @@ -144,12 +144,11 @@ int tcpreadtimeout(int s, unsigned char *buf, int num, int timeout) { for (len = 0; len < num; len += cnt) { FD_ZERO(&readfds); FD_SET(s, &readfds); - writefds = readfds; if (timeout) { timer.tv_sec = timeout; timer.tv_usec = 0; } - ndesc = select(s + 1, &readfds, &writefds, NULL, timeout ? &timer : NULL); + ndesc = select(s + 1, &readfds, NULL, NULL, timeout ? &timer : NULL); if (ndesc < 1) return ndesc; -- cgit v1.1