Use distinct read and except sets in select()

This commit is contained in:
Pieter Wuille 2020-10-09 19:44:29 -07:00
parent a1e9394284
commit 89929dab5c

View file

@ -221,9 +221,11 @@ public:
int64 now; int64 now;
while (now = time(NULL), ban == 0 && (doneAfter == 0 || doneAfter > now) && sock != INVALID_SOCKET) { while (now = time(NULL), ban == 0 && (doneAfter == 0 || doneAfter > now) && sock != INVALID_SOCKET) {
char pchBuf[0x10000]; char pchBuf[0x10000];
fd_set set; fd_set read_set, except_set;
FD_ZERO(&set); FD_ZERO(&read_set);
FD_SET(sock,&set); FD_ZERO(&except_set);
FD_SET(sock,&read_set);
FD_SET(sock,&except_set);
struct timeval wa; struct timeval wa;
if (doneAfter) { if (doneAfter) {
wa.tv_sec = doneAfter - now; wa.tv_sec = doneAfter - now;
@ -232,7 +234,7 @@ public:
wa.tv_sec = GetTimeout(); wa.tv_sec = GetTimeout();
wa.tv_usec = 0; wa.tv_usec = 0;
} }
int ret = select(sock+1, &set, NULL, &set, &wa); int ret = select(sock+1, &read_set, NULL, &except_set, &wa);
if (ret != 1) { if (ret != 1) {
if (!doneAfter) res = false; if (!doneAfter) res = false;
break; break;