mirror of
https://github.com/curl/curl.git
synced 2026-07-22 22:37:16 +03:00
Some systems poll function sets POLLHUP in revents without setting
POLLIN, and sets POLLERR without setting POLLIN and POLLOUT. In some libcurl code execution paths this could trigger busy wait loops with high CPU usage until a timeout condition aborted the loop. This fix for Curl_poll adresses the above in a libcurl-wide mode.
This commit is contained in:
parent
7e0b0763fc
commit
f7690db37d
1 changed files with 14 additions and 0 deletions
14
lib/select.c
14
lib/select.c
|
|
@ -398,6 +398,20 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||
}
|
||||
} while(r == -1);
|
||||
|
||||
if(r < 0)
|
||||
return -1;
|
||||
if(r == 0)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < nfds; i++) {
|
||||
if(ufds[i].fd == CURL_SOCKET_BAD)
|
||||
continue;
|
||||
if(ufds[i].revents & POLLHUP)
|
||||
ufds[i].revents |= POLLIN;
|
||||
if(ufds[i].revents & POLLERR)
|
||||
ufds[i].revents |= (POLLIN|POLLOUT);
|
||||
}
|
||||
|
||||
#else /* HAVE_POLL_FINE */
|
||||
|
||||
FD_ZERO(&fds_read);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue