From b8699caf508f8060559a88b67d2b9ddabf631f6a Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 25 Oct 2021 10:11:07 +0200 Subject: HttpAsioServer::Run() implementation for POSIX platforms --- zenhttp/httpasio.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'zenhttp/httpasio.cpp') diff --git a/zenhttp/httpasio.cpp b/zenhttp/httpasio.cpp index ea84e7e87..061cd607a 100644 --- a/zenhttp/httpasio.cpp +++ b/zenhttp/httpasio.cpp @@ -9,7 +9,9 @@ #include ZEN_THIRD_PARTY_INCLUDES_START -#include +#if ZEN_PLATFORM_WINDOWS +# include +#endif #include #include ZEN_THIRD_PARTY_INCLUDES_END @@ -1157,6 +1159,13 @@ HttpAsioServer::Run(bool IsInteractive) { const bool TestMode = !IsInteractive; + int WaitTimeout = -1; + if (!TestMode) + { + WaitTimeout = 1000; + } + +#if ZEN_PLATFORM_WINDOWS if (TestMode == false) { zen::logging::ConsoleLog().info("Zen Server running (asio HTTP). Press ESC or Q to quit"); @@ -1164,13 +1173,6 @@ HttpAsioServer::Run(bool IsInteractive) do { - int WaitTimeout = -1; - - if (!TestMode) - { - WaitTimeout = 1000; - } - if (!TestMode && _kbhit() != 0) { char c = (char)_getch(); @@ -1183,6 +1185,18 @@ HttpAsioServer::Run(bool IsInteractive) m_ShutdownEvent.Wait(WaitTimeout); } while (!IsApplicationExitRequested()); +#else + if (TestMode == false) + { + zen::logging::ConsoleLog().info("Zen Server running (asio HTTP). Ctrl-C to quit"); + } + + do + { + m_ShutdownEvent.Wait(WaitTimeout); + } + while (!IsApplicationExitRequested()); +#endif } void -- cgit v1.2.3