1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-24 09:08:49 -05:00

lib: don't compare fd to FD_SETSIZE when using poll

FD_SETSIZE is irrelevant when using poll. So ensuring that the file
descriptor is smaller than FD_SETSIZE in VALID_SOCK, can cause
multi_wait to ignore perfectly valid file descriptors and simply wait
for 1s to avoid hammering the CPU in a busy loop.

Fixes #7240
Closes #7241
This commit is contained in:
Mark Swaanenburg 2021-06-11 06:27:00 +00:00 committed by Daniel Stenberg
parent 23eef2394c
commit d293bf4a78
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -106,7 +106,11 @@ int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes,
} \
} while(0)
#else
#ifdef HAVE_POLL_FINE
#define VALID_SOCK(s) ((s) >= 0) /* FD_SETSIZE is irrelevant for poll */
#else
#define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE))
#endif
#define VERIFY_SOCK(x) do { \
if(!VALID_SOCK(x)) { \
SET_SOCKERRNO(EINVAL); \