summaryrefslogtreecommitdiff
path: root/lib/select.h
diff options
context:
space:
mode:
authorMark Swaanenburg <mswaanen@amazon.com>2021-06-11 06:27:00 +0000
committerDaniel Stenberg <daniel@haxx.se>2021-06-11 10:33:32 +0200
commitd293bf4a789e7a02dd5ea40bcd81d23698859641 (patch)
tree6552dbba6dfeec027f6217f865eb2f0bb3c7cdfd /lib/select.h
parent23eef2394cb810294a669d4bb4862bbdb2f5ced6 (diff)
downloadcurl-d293bf4a789e7a02dd5ea40bcd81d23698859641.tar.gz
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
Diffstat (limited to 'lib/select.h')
-rw-r--r--lib/select.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/select.h b/lib/select.h
index 4db64877b..19da1e774 100644
--- a/lib/select.h
+++ b/lib/select.h
@@ -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); \