aboutsummaryrefslogtreecommitdiff
path: root/zenhttp/httpasio.cpp
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2021-12-14 12:34:47 +0100
committerPer Larsson <[email protected]>2021-12-14 12:34:47 +0100
commitb6c6568e1618f10d2160d836b65e35586e3c740f (patch)
treef6a929cf918850bbba87d0ee67cd3482b2d50e24 /zenhttp/httpasio.cpp
parentFixed bug in z$ service returning partial cache records and enable small obje... (diff)
parentPartial revert b363c5b (diff)
downloadzen-b6c6568e1618f10d2160d836b65e35586e3c740f.tar.xz
zen-b6c6568e1618f10d2160d836b65e35586e3c740f.zip
Merged main.
Diffstat (limited to 'zenhttp/httpasio.cpp')
-rw-r--r--zenhttp/httpasio.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/zenhttp/httpasio.cpp b/zenhttp/httpasio.cpp
index 08cefc3bc..e1d417d06 100644
--- a/zenhttp/httpasio.cpp
+++ b/zenhttp/httpasio.cpp
@@ -10,7 +10,9 @@
#include <memory_resource>
ZEN_THIRD_PARTY_INCLUDES_START
-#include <conio.h>
+#if ZEN_PLATFORM_WINDOWS
+# include <conio.h>
+#endif
#include <http_parser.h>
#include <asio.hpp>
ZEN_THIRD_PARTY_INCLUDES_END
@@ -405,7 +407,7 @@ HttpServerConnection::OnDataReceived(const asio::error_code& Ec, [[maybe_unused]
ZEN_TRACE_VERBOSE("on data received, connection '{}', request '{}', thread '{}', bytes '{}'",
m_ConnectionId,
m_RequestCounter.load(std::memory_order_relaxed),
- GetCurrentThreadId(),
+ zen::GetCurrentThreadId(),
NiceBytes(ByteCount));
while (m_RequestBuffer.size())
@@ -443,7 +445,7 @@ HttpServerConnection::OnResponseDataSent(const asio::error_code& Ec, [[maybe_unu
ZEN_TRACE_VERBOSE("on data sent, connection '{}', request '{}', thread '{}', bytes '{}'",
m_ConnectionId,
m_RequestCounter.load(std::memory_order_relaxed),
- GetCurrentThreadId(),
+ zen::GetCurrentThreadId(),
NiceBytes(ByteCount));
if (!m_RequestData.IsKeepAlive())
@@ -1071,7 +1073,7 @@ HttpAsioServerRequest::WriteResponse(HttpResponseCode ResponseCode)
m_Response.reset(new HttpResponse(HttpContentType::kBinary));
std::array<IoBuffer, 0> Empty;
- m_Response->InitializeForPayload((UINT16)ResponseCode, Empty);
+ m_Response->InitializeForPayload((uint16_t)ResponseCode, Empty);
}
void
@@ -1080,7 +1082,7 @@ HttpAsioServerRequest::WriteResponse(HttpResponseCode ResponseCode, HttpContentT
ZEN_ASSERT(!m_Response);
m_Response.reset(new HttpResponse(ContentType));
- m_Response->InitializeForPayload((UINT16)ResponseCode, Blobs);
+ m_Response->InitializeForPayload((uint16_t)ResponseCode, Blobs);
}
void
@@ -1220,6 +1222,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");
@@ -1227,13 +1236,6 @@ HttpAsioServer::Run(bool IsInteractive)
do
{
- int WaitTimeout = -1;
-
- if (!TestMode)
- {
- WaitTimeout = 1000;
- }
-
if (!TestMode && _kbhit() != 0)
{
char c = (char)_getch();
@@ -1246,6 +1248,17 @@ 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