mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-14 21:19:08 +00:00
problem solved.. remove most of the old code again
This commit is contained in:
parent
ff1fecc7e6
commit
316ac7b04e
@ -148,16 +148,6 @@ bool receive_with_timeout(TCPsocket s, char* buf, size_t nbytes, bool update_sta
|
|||||||
{
|
{
|
||||||
int nsleeps = 0;
|
int nsleeps = 0;
|
||||||
while(nbytes > 0) {
|
while(nbytes > 0) {
|
||||||
#ifdef _WIN32
|
|
||||||
{
|
|
||||||
// if we are receiving the socket is in sockets_locked
|
|
||||||
// check if it is still locked
|
|
||||||
const threading::lock lock(*global_mutex);
|
|
||||||
if(sockets_locked[s] != SOCKET_LOCKED) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif //_WIN32
|
|
||||||
const int bytes_read = receive_bytes(s, buf, nbytes);
|
const int bytes_read = receive_bytes(s, buf, nbytes);
|
||||||
if(bytes_read == 0) {
|
if(bytes_read == 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -167,10 +157,10 @@ bool receive_with_timeout(TCPsocket s, char* buf, size_t nbytes, bool update_sta
|
|||||||
#elif defined(EWOULDBLOCK)
|
#elif defined(EWOULDBLOCK)
|
||||||
if(errno == EWOULDBLOCK)
|
if(errno == EWOULDBLOCK)
|
||||||
#else
|
#else
|
||||||
if(false)
|
// Ignore the error.
|
||||||
|
if(true)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
#ifdef USE_POLL
|
#ifdef USE_POLL
|
||||||
struct pollfd fd = { ((_TCPsocket*)s)->channel, POLLIN, 0 };
|
struct pollfd fd = { ((_TCPsocket*)s)->channel, POLLIN, 0 };
|
||||||
int poll_res;
|
int poll_res;
|
||||||
@ -195,17 +185,13 @@ bool receive_with_timeout(TCPsocket s, char* buf, size_t nbytes, bool update_sta
|
|||||||
|
|
||||||
if(retval > 0)
|
if(retval > 0)
|
||||||
continue;
|
continue;
|
||||||
#endif
|
#elif
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#else //_WIN32
|
|
||||||
//TODO: consider replacing this with a select call
|
//TODO: consider replacing this with a select call
|
||||||
if(++nsleeps == timeout_ms) {
|
if(++nsleeps == timeout_ms) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SDL_Delay(1000);
|
SDL_Delay(1000);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -214,16 +200,13 @@ bool receive_with_timeout(TCPsocket s, char* buf, size_t nbytes, bool update_sta
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //_WIN32
|
|
||||||
nbytes -= bytes_read;
|
nbytes -= bytes_read;
|
||||||
buf += bytes_read;
|
buf += bytes_read;
|
||||||
if(update_stats) {
|
if(update_stats) {
|
||||||
const threading::lock lock(*global_mutex);
|
const threading::lock lock(*global_mutex);
|
||||||
transfer_stats[s].second.transfer(static_cast<size_t>(bytes_read));
|
transfer_stats[s].second.transfer(static_cast<size_t>(bytes_read));
|
||||||
}
|
}
|
||||||
#ifndef _WIN32
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user