summaryrefslogtreecommitdiff
path: root/lib/select.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2007-01-02 22:34:56 +0000
committerDaniel Stenberg <daniel@haxx.se>2007-01-02 22:34:56 +0000
commit0682d25da5036d2b35e890808247e9203d28fcc4 (patch)
tree00323bb6dfe4436f8d9afd1ee189dd757362a8b6 /lib/select.c
parentd86d14074d1adf64fa3d401a0cbf05d0b77f38ae (diff)
downloadcurl-0682d25da5036d2b35e890808247e9203d28fcc4.tar.gz
- 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.
Diffstat (limited to 'lib/select.c')
-rw-r--r--lib/select.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/select.c b/lib/select.c
index 672e5b8cf..33a005e70 100644
--- a/lib/select.c
+++ b/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;