aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2013-12-24 23:50:49 -0500
committerkwolekr <kwolekr@minetest.net>2013-12-31 15:00:49 -0500
commit25b1cca4150a9f78b05b98afee71a97fd052df71 (patch)
tree88a21407f15b20c53b4240888a89fc8493b30e8c /src
parent767b2e7b175db54ec29bd270280b857586b1e836 (diff)
downloadminetest-25b1cca4150a9f78b05b98afee71a97fd052df71.tar.gz
minetest-25b1cca4150a9f78b05b98afee71a97fd052df71.tar.bz2
minetest-25b1cca4150a9f78b05b98afee71a97fd052df71.zip
Fix exception caused by destroying sockets on Server shutdown
Diffstat (limited to 'src')
-rw-r--r--src/socket.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index c3873dab6..78ff364e5 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -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)
{
@@ -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