diff options
author | Kahrl <kahrl@gmx.net> | 2013-12-24 19:28:09 +0100 |
---|---|---|
committer | Kahrl <kahrl@gmx.net> | 2013-12-24 19:28:09 +0100 |
commit | 3aa28bc7a2014dcefd9f24517ff32223bec32a35 (patch) | |
tree | 7ab99fd2867a0d1d2e9bdf5ecdf62eacf6feeaea /src/httpfetch.cpp | |
parent | a5377251e213803f61752594b7b52d31ac410bb2 (diff) | |
download | minetest-3aa28bc7a2014dcefd9f24517ff32223bec32a35.tar.gz minetest-3aa28bc7a2014dcefd9f24517ff32223bec32a35.tar.bz2 minetest-3aa28bc7a2014dcefd9f24517ff32223bec32a35.zip |
Use sleep_ms instead of select in httpfetch when max_fd == -1, fixes WSAEINVAL
Diffstat (limited to 'src/httpfetch.cpp')
-rw-r--r-- | src/httpfetch.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/httpfetch.cpp b/src/httpfetch.cpp index b48d00764..60e4591a9 100644 --- a/src/httpfetch.cpp +++ b/src/httpfetch.cpp @@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "socket.h" // for select() +#include "porting.h" // for sleep_ms() #include "httpfetch.h" #include <iostream> #include <sstream> @@ -520,19 +521,26 @@ protected: 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 == -1) { + 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); } } } |