http.c: Use curl_multi_fdset to select on curl fds instead of just sleeping
Instead of sleeping unconditionally for a 50ms, when no data can be read from the http connection(s), use curl_multi_fdset() to obtain the actual file descriptors of the open connections and use them in the select call. This way, the 50ms sleep is interrupted when new data arrives. Signed-off-by: Mika Fischer <mika.fischer@zoopnet.de> Helped-by: Daniel Stenberg <daniel@haxx.se> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Mika Fischer committed
Nov 4, 2011 at 15:19 UTC
6f9dd67ffea3e86276a73e522ce1186a99bbe65d
1 file changed
+3
-3
http.c
+3
-3
@@ -651,14 +651,14 @@ void run_active_slot(struct active_request_slot *slot)
651
}
652
653
if (slot->in_use && !data_received) {
654
- max_fd = 0;
654
+ max_fd = -1;
655
FD_ZERO(&readfds);
656
FD_ZERO(&writefds);
657
FD_ZERO(&excfds);
658
+ curl_multi_fdset(curlm, &readfds, &writefds, &excfds, &max_fd);
659
select_timeout.tv_sec = 0;
660
select_timeout.tv_usec = 50000;
660
- select(max_fd, &readfds, &writefds,
661
- &excfds, &select_timeout);
661
+ select(max_fd+1, &readfds, &writefds, &excfds, &select_timeout);
662
}
663
}
664
#else