From a4e6a027a19af1f68e761331043c1b80b000a3cb Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 23 Mar 2013 22:02:35 +0000 Subject: 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 --- source/OSSupport/ListenThread.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/OSSupport') diff --git a/source/OSSupport/ListenThread.cpp b/source/OSSupport/ListenThread.cpp index 27c77a897..9e2a07f3c 100644 --- a/source/OSSupport/ListenThread.cpp +++ b/source/OSSupport/ListenThread.cpp @@ -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; -- cgit v1.2.3