Fix segfault in http

This commit is contained in:
Lion Kortlepel
2021-12-06 10:22:52 +01:00
parent 62cc1e9ce4
commit 279c93179c
3 changed files with 15 additions and 10 deletions

View File

@@ -26,7 +26,7 @@ const std::string ErrorString = "-1";
namespace Server {
void SetupEnvironment();
// todo: Add non TLS Server Instance, this one is TLS only
class THttpServerInstance : IThreaded {
class THttpServerInstance {
public:
THttpServerInstance();
static fs::path KeyFilePath;
@@ -42,6 +42,7 @@ namespace Server {
* So we need to able to start the server (make it "listen()") in a single Thread.
*/
std::shared_ptr<httplib::SSLServer> mHttpLibServerInstancePtr;
std::thread mThread;
};
// todo: all of these functions are likely unsafe,
// todo: replace with something that's managed by a domain specific crypto library

View File

@@ -8,11 +8,11 @@ public:
IThreaded()
// invokes operator() on this object
: mThread() { }
~IThreaded() noexcept {
if (mThread.joinable()) {
mThread.join();
}
~IThreaded() noexcept {
if (mThread.joinable()) {
mThread.join();
}
}
virtual void Start() final {
mThread = std::thread([this] { (*this)(); });