From cc7ef1b275deb4c7766927aedb221228af534b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt-Alexander=20Mokro=C3=9F?= Date: Tue, 5 Jan 2021 21:49:28 +0100 Subject: [PATCH] Fix wrong calling of conditional loop if condition is null (Closes #372( --- src/oatpp/network/Server.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/oatpp/network/Server.cpp b/src/oatpp/network/Server.cpp index 6d4326b2..5fce1697 100644 --- a/src/oatpp/network/Server.cpp +++ b/src/oatpp/network/Server.cpp @@ -103,10 +103,14 @@ void Server::run(std::function conditional) { m_threaded = false; setStatus(STATUS_CREATED, STATUS_STARTING); - m_condition = std::move(conditional); - - ul.unlock(); // early unlock - conditionalMainLoop(); + if (conditional) { + m_condition = std::move(conditional); + ul.unlock(); // early unlock + conditionalMainLoop(); + } else { + ul.unlock(); + mainLoop(this); + } } void Server::run(bool startAsNewThread) {