From 0ee89539ead8631b02953ddf601770aefa557edb Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Fri, 17 Sep 2021 23:18:20 +0200 Subject: zenserver can now run as a Windows service. We'll still need to improve how data files are found as the current defaults are relative to the user directory which ends up being in the Windows folder when running as the local system user --- zenhttp/httpsys.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'zenhttp/httpsys.cpp') diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp index c2d4ef14c..b5313021c 100644 --- a/zenhttp/httpsys.cpp +++ b/zenhttp/httpsys.cpp @@ -707,29 +707,30 @@ HttpSysServer::StartServer() } void -HttpSysServer::Run(bool TestMode) +HttpSysServer::Run(bool IsInteractive) { - if (TestMode == false) + if (IsInteractive) { zen::logging::ConsoleLog().info("Zen Server running. Press ESC or Q to quit"); } do { - int WaitTimeout = -1; + //int WaitTimeout = -1; + int WaitTimeout = 100; - if (!TestMode) + if (IsInteractive) { WaitTimeout = 1000; - } - - if (!TestMode && _kbhit() != 0) - { - char c = (char)_getch(); - if (c == 27 || c == 'Q' || c == 'q') + if (_kbhit() != 0) { - RequestApplicationExit(0); + char c = (char)_getch(); + + if (c == 27 || c == 'Q' || c == 'q') + { + RequestApplicationExit(0); + } } } -- cgit v1.2.3 From 1e5b41352c7d45f34cb1a51e3d3811a4a994592a Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Sun, 19 Sep 2021 19:31:13 +0200 Subject: clang-format again --- zenhttp/httpsys.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zenhttp/httpsys.cpp') diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp index b5313021c..3c5e5d8d3 100644 --- a/zenhttp/httpsys.cpp +++ b/zenhttp/httpsys.cpp @@ -716,7 +716,7 @@ HttpSysServer::Run(bool IsInteractive) do { - //int WaitTimeout = -1; + // int WaitTimeout = -1; int WaitTimeout = 100; if (IsInteractive) -- cgit v1.2.3 From 30489520435b2a52453a455c474d2c3ae05359db Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 20 Sep 2021 20:47:47 +0200 Subject: Improved error handling in http.sys handler Alsod fixed lifetime issue with initial request --- zenhttp/httpsys.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'zenhttp/httpsys.cpp') diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp index 3c5e5d8d3..7ce970d15 100644 --- a/zenhttp/httpsys.cpp +++ b/zenhttp/httpsys.cpp @@ -415,7 +415,7 @@ HttpMessageResponseRequest::HandleCompletion(ULONG IoResult, ULONG_PTR NumberOfB { ZEN_UNUSED(NumberOfBytesTransferred); - if (IoResult) + if (IoResult != NO_ERROR) { ZEN_WARN("response aborted due to error: '{}'", GetWindowsErrorAsString(IoResult)); @@ -898,9 +898,7 @@ HttpSysTransaction::HandleCompletion(ULONG IoResult, ULONG_PTR NumberOfBytesTran if (HttpSysRequestHandler* CurrentHandler = m_CompletionHandler) { - const bool IsInitialRequest = (CurrentHandler == &m_InitialHttpHandler) && m_InitialHttpHandler.IsInitialRequest(); - - if (IsInitialRequest) + if ((CurrentHandler == &m_InitialHttpHandler) && m_InitialHttpHandler.IsInitialRequest()) { // Ensure we have a sufficient number of pending requests outstanding m_HttpServer.OnHandlingRequest(); @@ -933,7 +931,7 @@ HttpSysTransaction::HandleCompletion(ULONG IoResult, ULONG_PTR NumberOfBytesTran } else { - if (IsInitialRequest == false) + if (CurrentHandler != &m_InitialHttpHandler) { delete CurrentHandler; } @@ -1254,11 +1252,12 @@ InitialRequestHandler::HandleCompletion(ULONG IoResult, ULONG_PTR NumberOfBytesT switch (IoResult) { + default: case ERROR_OPERATION_ABORTED: return nullptr; - case ERROR_MORE_DATA: - // Insufficient buffer space + case ERROR_MORE_DATA: // Insufficient buffer space + case NO_ERROR: break; } -- cgit v1.2.3