summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Satiro <raysatiro@yahoo.com>2020-03-05 23:35:32 -0500
committerJay Satiro <raysatiro@yahoo.com>2020-03-06 02:56:21 -0500
commit2258b7bcc265b5fe9bfa79ddd079f57e61557da7 (patch)
tree8cfb21a2717d8988dd85784a76f16e7e7a902c4c
parent0b7735c45bf36b71f5b93ef334520b3abc301aea (diff)
downloadcurl-2258b7bcc265b5fe9bfa79ddd079f57e61557da7.tar.gz
multi: skip EINTR check on wakeup socket if it was closed
- Don't check errno on wakeup socket if sread returned 0 since sread doesn't set errno in that case. This is a follow-up to cf7760a from several days ago which fixed Curl_multi_wait to stop busy looping sread on the non-blocking wakeup socket if it was closed (ie sread returns 0). Due to a logic error it was still possible to busy loop in that case if errno == EINTR. Closes https://github.com/curl/curl/pull/5047
-rw-r--r--lib/multi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/multi.c b/lib/multi.c
index cef2805c8..e10e75293 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -1194,14 +1194,16 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
if(use_wakeup && multi->wakeup_pair[0] != CURL_SOCKET_BAD) {
if(ufds[curlfds + extra_nfds].revents & POLLIN) {
char buf[64];
+ ssize_t nread;
while(1) {
/* the reading socket is non-blocking, try to read
data from it until it receives an error (except EINTR).
In normal cases it will get EAGAIN or EWOULDBLOCK
when there is no more data, breaking the loop. */
- if(sread(multi->wakeup_pair[0], buf, sizeof(buf)) <= 0) {
+ nread = sread(multi->wakeup_pair[0], buf, sizeof(buf));
+ if(nread <= 0) {
#ifndef USE_WINSOCK
- if(EINTR == SOCKERRNO)
+ if(nread < 0 && EINTR == SOCKERRNO)
continue;
#endif
break;