mirror of
https://github.com/curl/curl.git
synced 2026-08-24 20:23:40 +03:00
- Victor Snezhko helped us fix bug report #1603712
(http://curl.haxx.se/bug/view.cgi?id=1603712) (known bug #36) --limit-rate (CURLOPT_MAX_SEND_SPEED_LARGE and CURLOPT_MAX_RECV_SPEED_LARGE) are broken on Windows (since 7.16.0, but that's when they were introduced as previous to that the limiting logic was made in the application only and not in the library). It was actually also broken on select()-based systems (as apposed to poll()) but we haven't had any such reports. We now use select(), Sleep() or delay() properly to sleep a while without waiting for anything input or output when the rate limiting is activated with the easy interface.
This commit is contained in:
parent
d86d14074d
commit
0682d25da5
4 changed files with 31 additions and 9 deletions
17
lib/select.c
17
lib/select.c
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
|
@ -141,6 +141,21 @@ int Curl_select(curl_socket_t readfd, curl_socket_t writefd, int timeout_ms)
|
|||
timeout.tv_sec = timeout_ms / 1000;
|
||||
timeout.tv_usec = (timeout_ms % 1000) * 1000;
|
||||
|
||||
if((readfd == CURL_SOCKET_BAD) && (writefd == CURL_SOCKET_BAD)) {
|
||||
/* According to POSIX we should pass in NULL pointers if we don't want to
|
||||
wait for anything in particular but just use the timeout function.
|
||||
Windows however returns immediately if done so. I copied the MSDOS
|
||||
delay() use from src/main.c that already had this work-around. */
|
||||
#ifdef WIN32
|
||||
Sleep(timeout_ms);
|
||||
#elif defined(__MSDOS__)
|
||||
delay(ms);
|
||||
#else
|
||||
select(0, NULL, NULL, NULL, &timeout);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
FD_ZERO(&fds_err);
|
||||
maxfd = (curl_socket_t)-1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue