summaryrefslogtreecommitdiffhomepage
path: root/NetEx
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-03-30 18:55:34 +0200
committerAki <please@ignore.pl>2022-03-30 18:55:34 +0200
commit1c17ced79815c94d704bc042f22dc5a0df1df187 (patch)
tree98ccc2e248a9c384e5038ba6c9a4b84a50468530 /NetEx
parent51df86b38668f413c078fd96a0b8828dcd8561ef (diff)
downloadstarshatter-1c17ced79815c94d704bc042f22dc5a0df1df187.zip
starshatter-1c17ced79815c94d704bc042f22dc5a0df1df187.tar.gz
starshatter-1c17ced79815c94d704bc042f22dc5a0df1df187.tar.bz2
Removed windows header uses in HttpServletExec
Diffstat (limited to 'NetEx')
-rw-r--r--NetEx/HttpServletExec.cpp33
-rw-r--r--NetEx/HttpServletExec.h9
2 files changed, 13 insertions, 29 deletions
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 <stdio.h>
-#include <windows.h>
+
+#include <cstdint>
+#include <thread>
#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;
}
diff --git a/NetEx/HttpServletExec.h b/NetEx/HttpServletExec.h
index 8c9fd2b..8f06d73 100644
--- a/NetEx/HttpServletExec.h
+++ b/NetEx/HttpServletExec.h
@@ -14,7 +14,8 @@
#ifndef HttpServletExec_h
#define HttpServletExec_h
-#include <windows.h>
+#include <cstdint>
+#include <thread>
#include "HttpRequest.h"
#include "HttpResponse.h"
@@ -29,7 +30,7 @@ class HttpServletExec : public HttpServer
public:
static const char* TYPENAME() { return "HttpServletExec"; }
- HttpServletExec(WORD port, int poolsize=1);
+ HttpServletExec(std::uint16_t port, int poolsize=1);
virtual ~HttpServletExec();
int operator == (const HttpServletExec& l) const { return addr == l.addr; }
@@ -39,7 +40,7 @@ public:
virtual HttpServlet* GetServlet(HttpRequest& request);
virtual HttpSession* GetSession(HttpRequest& request);
- virtual DWORD CheckSessions();
+ virtual void CheckSessions();
virtual int GetSessionTimeout() const { return session_timeout; }
virtual void SetSessionTimeout(int t) { session_timeout = t; }
@@ -49,7 +50,7 @@ protected:
List<HttpSession> sessions;
int session_timeout;
- HANDLE hsession;
+ std::thread hsession;
bool exec_shutdown;
};