Created
December 23, 2013 23:15
-
-
Save kahrl/8106473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/httpfetch.cpp b/src/httpfetch.cpp | |
index b48d007..ff48cc3 100644 | |
--- a/src/httpfetch.cpp | |
+++ b/src/httpfetch.cpp | |
@@ -18,6 +18,7 @@ | |
*/ | |
#include "socket.h" // for select() | |
+#include "porting.h" // for sleep_ms() | |
#include "httpfetch.h" | |
#include <iostream> | |
#include <sstream> | |
@@ -520,19 +521,26 @@ class CurlFetchThread : public JThread | |
select_timeout = timeout; | |
if (select_timeout > 0) { | |
- select_tv.tv_sec = select_timeout / 1000; | |
- select_tv.tv_usec = (select_timeout % 1000) * 1000; | |
- int retval = select(max_fd + 1, &read_fd_set, | |
- &write_fd_set, &exc_fd_set, | |
- &select_tv); | |
- if (retval == -1) { | |
- #ifdef _WIN32 | |
- errorstream<<"select returned error code " | |
- <<WSAGetLastError()<<std::endl; | |
- #else | |
- errorstream<<"select returned error code " | |
- <<errno<<std::endl; | |
- #endif | |
+ // in Winsock it is forbidden to pass three empty | |
+ // fd_sets to select(), so in that case use sleep_ms | |
+ if (max_fd < 0) { | |
+ select_tv.tv_sec = select_timeout / 1000; | |
+ select_tv.tv_usec = (select_timeout % 1000) * 1000; | |
+ int retval = select(max_fd + 1, &read_fd_set, | |
+ &write_fd_set, &exc_fd_set, | |
+ &select_tv); | |
+ if (retval == -1) { | |
+ #ifdef _WIN32 | |
+ errorstream<<"select returned error code " | |
+ <<WSAGetLastError()<<std::endl; | |
+ #else | |
+ errorstream<<"select returned error code " | |
+ <<errno<<std::endl; | |
+ #endif | |
+ } | |
+ } | |
+ else { | |
+ sleep_ms(select_timeout); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment