From 1c17ced79815c94d704bc042f22dc5a0df1df187 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 30 Mar 2022 18:55:34 +0200 Subject: Removed windows header uses in HttpServletExec --- NetEx/HttpServletExec.cpp | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'NetEx/HttpServletExec.cpp') diff --git a/NetEx/HttpServletExec.cpp b/NetEx/HttpServletExec.cpp index e7e1c2b..bbd7efe 100644 --- a/NetEx/HttpServletExec.cpp +++ b/NetEx/HttpServletExec.cpp @@ -14,7 +14,9 @@ #include "HttpServletExec.h" #include -#include + +#include +#include #include "HttpRequest.h" #include "HttpResponse.h" @@ -93,18 +95,13 @@ public: }; -DWORD WINAPI HttpServletExecSessionProc(LPVOID link); - - -HttpServletExec::HttpServletExec(WORD port, int poolsize) : +HttpServletExec::HttpServletExec(std::uint16_t port, int poolsize) : HttpServer(port, poolsize), session_timeout(60), exec_shutdown(false) { http_server_name = "Generic HttpServletExec 1.0"; - - DWORD thread_id = 0; - hsession = CreateThread(0, 4096, HttpServletExecSessionProc, (LPVOID) this, 0, &thread_id); + hsession = std::thread([&]{ CheckSessions(); }); } @@ -113,9 +110,8 @@ HttpServletExec::~HttpServletExec() if (!exec_shutdown) exec_shutdown = true; - WaitForSingleObject(hsession, 1000); - CloseHandle(hsession); - hsession = 0; + if (hsession.joinable()) + hsession.join(); sessions.destroy(); } @@ -189,18 +185,7 @@ HttpServletExec::DoGet(HttpRequest& request, HttpResponse& response) } -DWORD WINAPI HttpServletExecSessionProc(LPVOID link) -{ - HttpServletExec* exec = (HttpServletExec*) link; - - if (exec) - return exec->CheckSessions(); - - return (DWORD) E_POINTER; -} - - -DWORD +void HttpServletExec::CheckSessions() { while (!exec_shutdown) { @@ -223,8 +208,6 @@ HttpServletExec::CheckSessions() sync.unlock(); Sleep(100); } - - return 0; } -- cgit v1.1