Commit 46e97b76 authored by Linus Nordberg's avatar Linus Nordberg

Don't wait for _writable_ when _reading_ a TCP socket.

Like 92a0c39a for TCP.

Patch by Fabian Mauchle.
parent cc68bc85
...@@ -135,7 +135,7 @@ int tcpconnect(struct server *server, struct timeval *when, int timeout, char *t ...@@ -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 */ /* returns 0 on timeout, -1 on error and num if ok */
int tcpreadtimeout(int s, unsigned char *buf, int num, int timeout) { int tcpreadtimeout(int s, unsigned char *buf, int num, int timeout) {
int ndesc, cnt, len; int ndesc, cnt, len;
fd_set readfds, writefds; fd_set readfds;
struct timeval timer; struct timeval timer;
if (s < 0) if (s < 0)
...@@ -144,12 +144,11 @@ int tcpreadtimeout(int s, unsigned char *buf, int num, int timeout) { ...@@ -144,12 +144,11 @@ int tcpreadtimeout(int s, unsigned char *buf, int num, int timeout) {
for (len = 0; len < num; len += cnt) { for (len = 0; len < num; len += cnt) {
FD_ZERO(&readfds); FD_ZERO(&readfds);
FD_SET(s, &readfds); FD_SET(s, &readfds);
writefds = readfds;
if (timeout) { if (timeout) {
timer.tv_sec = timeout; timer.tv_sec = timeout;
timer.tv_usec = 0; 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) if (ndesc < 1)
return ndesc; return ndesc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment