Skip to content

Commit c01f955

Browse files
committed
multi: work correctly in case of no sockets
Fix WinSock version to work correctly in case no sockets are to be waited on and just the WinSock event is being monitored for wakeup functionality.
1 parent f5605ea commit c01f955

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

lib/multi.c

+15-8
Original file line numberDiff line numberDiff line change
@@ -1247,13 +1247,19 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
12471247
#endif
12481248
#endif
12491249

1250+
#if defined(ENABLE_WAKEUP) && defined(USE_WINSOCK)
1251+
if(nfds || use_wakeup) {
1252+
#else
12501253
if(nfds) {
1254+
#endif
12511255
int pollrc;
12521256
#ifdef USE_WINSOCK
1253-
pollrc = Curl_poll(ufds, nfds, 0); /* just pre-check with WinSock */
1254-
if(pollrc <= 0) { /* now wait... if not ready during the pre-check above */
1255-
WSAWaitForMultipleEvents(1, &multi->wsa_event, FALSE, timeout_ms, FALSE);
1256-
}
1257+
if(nfds)
1258+
pollrc = Curl_poll(ufds, nfds, 0); /* just pre-check with WinSock */
1259+
else
1260+
pollrc = 0;
1261+
if(pollrc <= 0) /* now wait... if not ready during the pre-check above */
1262+
WSAWaitForMultipleEvents(1, &multi->wsa_event, FALSE, timeout_ms, FALSE);
12571263
#else
12581264
pollrc = Curl_poll(ufds, nfds, timeout_ms); /* wait... */
12591265
#endif
@@ -1354,10 +1360,11 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
13541360
free(ufds);
13551361
if(ret)
13561362
*ret = retcode;
1357-
if(!extrawait || nfds)
1358-
/* if any socket was checked */
1359-
;
1360-
else {
1363+
#if defined(ENABLE_WAKEUP) && defined(USE_WINSOCK)
1364+
if(extrawait && !nfds && !use_wakeup) {
1365+
#else
1366+
if(extrawait && !nfds) {
1367+
#endif
13611368
long sleep_ms = 0;
13621369

13631370
/* Avoid busy-looping when there's nothing particular to wait for */

0 commit comments

Comments
 (0)