Skip to content

Commit

Permalink
Fix deadlock on server shutdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
lPrimemaster committed Feb 10, 2025
1 parent eb1afb1 commit 44dad55
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions network/mxhttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,10 @@ namespace mulex
std::string respath = serveDir + urlPath;
if(!std::filesystem::is_regular_file(respath))
{
// If the file is not found then route back to index.html
// solidjs router will figure out the route from the full url
urlPath = "/index.html";
respath = serveDir + urlPath;
// LogError("[mxhttp] Failed to serve files. Resource <%s> not found.", respath.c_str());
// res->writeStatus("404 Not Found")->end("<h1>404 - File Not Found<h1>");
// return false;
}

std::string data = HttpReadFileFromDisk(respath);
Expand Down Expand Up @@ -457,7 +456,7 @@ namespace mulex
static void HttpDeferCallAll(std::function<void(decltype(_active_ws_connections)::key_type)> func)
{
_ws_loop_thread->defer([&func]() {
std::lock_guard<std::mutex> lock(_mutex); // Given defer this should not be needed
// std::lock_guard<std::mutex> lock(_mutex); // Given defer this should not be needed
for(auto* ws : _active_ws_connections)
{
func(ws);
Expand Down Expand Up @@ -729,6 +728,8 @@ namespace mulex
LogError("[mxhttp] Failed to listen on port %d.", port);
}
}).run();

LogDebug("[mxhttp] Server graceful shutdown.");
});
}

Expand Down

0 comments on commit 44dad55

Please sign in to comment.