Skip to content

Commit

Permalink
Fix exception caused by destroying sockets on Server shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
kwolekr committed Dec 31, 2013
1 parent 767b2e7 commit 25b1cca
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/socket.cpp
Expand Up @@ -546,7 +546,10 @@ bool UDPSocket::WaitData(int timeout_ms)

if(result == 0)
return false;
else if(result < 0 && errno == EINTR)
else if(result < 0 && (errno == EINTR || errno == EBADF))
// N.B. select() fails when sockets are destroyed on Connection's dtor
// with EBADF. Instead of doing tricky synchronization, allow this
// thread to exit but don't throw an exception.
return false;
else if(result < 0)
{
Expand All @@ -557,9 +560,9 @@ bool UDPSocket::WaitData(int timeout_ms)
int e = WSAGetLastError();
dstream << (int) m_handle << ": WSAGetLastError()="
<< e << std::endl;
if(e == 10004 /* = WSAEINTR */)
if(e == 10004 /* = WSAEINTR */ || e == 10009 /*WSAEBADF*/)
{
dstream << "WARNING: Ignoring WSAEINTR." << std::endl;
dstream << "WARNING: Ignoring WSAEINTR/WSAEBADF." << std::endl;
return false;
}
#endif
Expand Down

0 comments on commit 25b1cca

Please sign in to comment.