From dfd453ae058401a916ec764a42c4ea6bf3e38ff3 Mon Sep 17 00:00:00 2001 From: Kent Gustavsson Date: Sun, 25 Jun 2023 14:43:08 +0200 Subject: [PATCH] fix so failed accept doesn't terminate the server Signed-off-by: Kent Gustavsson --- library/RemoteServer.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/library/RemoteServer.cpp b/library/RemoteServer.cpp index 77510d63a..7f40bead4 100644 --- a/library/RemoteServer.cpp +++ b/library/RemoteServer.cpp @@ -476,11 +476,14 @@ void ServerMainImpl::threadFn(std::promise promise, int port) CActiveSocket *client = nullptr; try { - while ((client = server.socket.Accept()) != NULL) + while (server.socket.IsSocketValid()) { - BlockGuard lock; - ServerConnection::Accepted(client); - client = nullptr; + if ((client = server.socket.Accept()) != NULL) + { + BlockGuard lock; + ServerConnection::Accepted(client); + client = nullptr; + } } } catch(BlockedException &) { if (client)