Skip to content

Commit

Permalink
Avoid double-close of Web Server socket on shutdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
rerdavies committed Nov 22, 2024
1 parent 1c071ba commit 6c0622a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 30 deletions.
22 changes: 2 additions & 20 deletions src/WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1340,30 +1340,12 @@ namespace pipedal
StopListening();

//linger bit to see of connections will shut down normally
if(WaitForAllEndpointsClosed(timeoutMs/2))
{
return;
}
Lv2Log::warning("WebServer: forcibly closing connections");

{
std::lock_guard<std::recursive_mutex> lock{m_sessionsMutex};
for (auto it = m_connections.begin(); it != m_connections.end(); ++it)
{
try
{
m_endpoint.close(*it, websocketpp::close::status::abnormal_close, "Shutting down");
}
catch (const std::exception &ignored)
{
}
}
}
if(WaitForAllEndpointsClosed(timeoutMs/2))
if(WaitForAllEndpointsClosed(timeoutMs))
{
return;
}
Lv2Log::warning("WebServer: failed to close all connections.");
return;

}
virtual void Join()
Expand Down
7 changes: 0 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ static bool isJackServiceRunning()
return std::filesystem::exists(path);
}

static void AsanCheck()
{
char *t = new char[5];
t[5] = 'x';
delete t;
exit(EXIT_FAILURE);
}

#if ENABLE_BACKTRACE
void segvHandler(int sig) {
Expand Down
4 changes: 1 addition & 3 deletions src/templates/pipedald.service.template
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ User=pipedal_d
Group=pipedal_d
Restart=always
TimeoutStartSec=60
NotifyAccess=all
RestartSec=5
TimeoutStopSec=15
WorkingDirectory=/var/pipedal
Environment=JACK_PROMISCUOUS_SERVER=audio
Environment=JACK_NO_AUDIO_RESERVATION=1



[Install]
Expand Down

0 comments on commit 6c0622a

Please sign in to comment.