- Victor Snezhko helped us fix bug report #1603712
authorDaniel Stenberg <daniel@haxx.se>
Tue, 2 Jan 2007 22:34:56 +0000 (22:34 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 2 Jan 2007 22:34:56 +0000 (22:34 +0000)
  (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.

CHANGES
RELEASE-NOTES
docs/KNOWN_BUGS
lib/select.c

diff --git a/CHANGES b/CHANGES
index 1cd5ccb..4e58026 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,16 @@
                                   Changelog
 
 Daniel (2 January 2007)
+- 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.
+
 - Modified libcurl.pc.in to use Libs.private for the libs libcurl itself needs
   to get built static. It has been mentioned before and was again brought to
   our attention by Nathanael Nerode who filed debian bug report #405226
index b53e2a3..33fee20 100644 (file)
@@ -42,6 +42,9 @@ This release includes the following bugfixes:
    would still make libcurl use the proxy...
  o curl_easy_duphandle() now makes a handle that is valid for the multi
    interface since the magic number is set fine
+ o libcurl.pc now uses Libs.private for "private" libs
+ o --limit-rate (CURLOPT_MAX_SEND_SPEED_LARGE and CURLOPT_MAX_RECV_SPEED_LARGE)
+   now work on windows again
 
 Other curl-related news:
 
@@ -61,6 +64,7 @@ advice from friends like these:
  Ciprian Badescu, Dmitriy Sergeyev, Nir Soffer, Venkat Akella, Toon Verwaest,
  Matt Witherspoon, Alexey Simak, Martin Skinner, Sh Diao, Jared Lundell,
  Stefan Krause, Sebastien Willemijns, Alexey Simak, Brendan Jurd,
- Robson Braga Araujo, David McCreedy, Robert Foreman
+ Robson Braga Araujo, David McCreedy, Robert Foreman, Nathanael Nerode,
+ Victor Snezhko
 
         Thanks! (and sorry if I forgot to mention someone)
index 3c25d9f..2ccabb8 100644 (file)
@@ -10,13 +10,6 @@ may have been fixed since this was written!
   when doing the different passes in the NTLM negotiation and thus fail to
   negotiate (in seemingly mysterious ways).
 
-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). This problem is easily
-  repeated and it takes a Windows person to fire up his/hers debugger in order
-  to fix. http://curl.haxx.se/bug/view.cgi?id=1603712
-
 35. Both SOCKS5 and SOCKS4 proxy connections are done blocking, which is very
   bad when used with the multi interface.
 
index 672e5b8..33a005e 100644 (file)
@@ -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;