Fixed a problem in Linux handling of ListenThread.

A closed socket doesn't seem to wake up a select() call on that socket on Linux. Fixed by waking up by a timeout regularly (semi-busywait).
Fixes FS #334

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1305 0a769ca7-a7f5-676a-18bf-c427514a06d6
master
madmaxoft@gmail.com 2013-03-23 22:02:35 +00:00
parent 561f105394
commit a4e6a027a1
1 changed files with 4 additions and 1 deletions

View File

@ -205,7 +205,10 @@ void cListenThread::Execute(void)
FD_SET(itr->GetSocket(), &fdRead);
} // for itr - m_Sockets[]
if (select(Highest + 1, &fdRead, NULL, NULL, NULL) == -1)
timeval tv; // On Linux select() doesn't seem to wake up when socket is closed, so let's kinda busy-wait:
tv.tv_sec = 1;
tv.tv_usec = 0;
if (select(Highest + 1, &fdRead, NULL, NULL, &tv) == -1)
{
LOG("select(R) call failed in cListenThread: \"%s\"", cSocket::GetLastErrorString().c_str());
continue;