summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2016-09-19 10:08:23 +0200
committerLinus Nordberg <linus@nordu.net>2016-09-19 10:08:45 +0200
commit6c1f37d727afb31ac3fa4af4a4158993897d402d (patch)
tree99e3461c2413d25921babd39fe40c602356abbeb
parent73ca00bfa8bef34dc0a4ff0a276a299c54ca980c (diff)
Don't wait for _writable_ when _reading_ a TCP socket.
Like 92a0c39a for TCP. Patch by Fabian Mauchle.
-rw-r--r--tcp.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/tcp.c b/tcp.c
index a2f8e7c..11bad5e 100644
--- a/tcp.c
+++ b/tcp.c
@@ -131,7 +131,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)
@@ -140,12 +140,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;