mirror of
https://github.com/minetest/minetest.git
synced 2024-11-24 00:23:46 +01:00
Use sleep_ms instead of select in httpfetch when max_fd == -1, fixes WSAEINVAL
This commit is contained in:
parent
a5377251e2
commit
3aa28bc7a2
@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "socket.h" // for select()
|
#include "socket.h" // for select()
|
||||||
|
#include "porting.h" // for sleep_ms()
|
||||||
#include "httpfetch.h"
|
#include "httpfetch.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -520,19 +521,26 @@ protected:
|
|||||||
select_timeout = timeout;
|
select_timeout = timeout;
|
||||||
|
|
||||||
if (select_timeout > 0) {
|
if (select_timeout > 0) {
|
||||||
select_tv.tv_sec = select_timeout / 1000;
|
// in Winsock it is forbidden to pass three empty
|
||||||
select_tv.tv_usec = (select_timeout % 1000) * 1000;
|
// fd_sets to select(), so in that case use sleep_ms
|
||||||
int retval = select(max_fd + 1, &read_fd_set,
|
if (max_fd == -1) {
|
||||||
&write_fd_set, &exc_fd_set,
|
select_tv.tv_sec = select_timeout / 1000;
|
||||||
&select_tv);
|
select_tv.tv_usec = (select_timeout % 1000) * 1000;
|
||||||
if (retval == -1) {
|
int retval = select(max_fd + 1, &read_fd_set,
|
||||||
#ifdef _WIN32
|
&write_fd_set, &exc_fd_set,
|
||||||
errorstream<<"select returned error code "
|
&select_tv);
|
||||||
<<WSAGetLastError()<<std::endl;
|
if (retval == -1) {
|
||||||
#else
|
#ifdef _WIN32
|
||||||
errorstream<<"select returned error code "
|
errorstream<<"select returned error code "
|
||||||
<<errno<<std::endl;
|
<<WSAGetLastError()<<std::endl;
|
||||||
#endif
|
#else
|
||||||
|
errorstream<<"select returned error code "
|
||||||
|
<<errno<<std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sleep_ms(select_timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user