From 1838a3922caffdeb70501cdce6215bfcfcfbbf0b Mon Sep 17 00:00:00 2001 From: Frederik Seiffert Date: Tue, 17 Jan 2023 10:26:02 +0100 Subject: [PATCH] Don't crash due to closed socket on Windows --- src/event/event_windows.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/event/event_windows.c b/src/event/event_windows.c index 94674a3bf..148c9de9a 100644 --- a/src/event/event_windows.c +++ b/src/event/event_windows.c @@ -219,7 +219,11 @@ _dispatch_muxnote_disarm_events(dispatch_muxnote_t dmn, iResult = WSAEventSelect((SOCKET)dmn->dmn_ident, NULL, 0); } if (iResult != 0) { - DISPATCH_INTERNAL_CRASH(WSAGetLastError(), "WSAEventSelect"); + // ignore error if socket was already closed + int err = WSAGetLastError(); + if (err != WSAENOTSOCK) { + DISPATCH_INTERNAL_CRASH(err, "WSAEventSelect"); + } } dmn->dmn_network_events = lNetworkEvents; if (!lNetworkEvents && dmn->dmn_threadpool_wait) {