Skip to content

Commit

Permalink
Fix libwebsocket shutdown behavior (#267)
Browse files Browse the repository at this point in the history
Signed-off-by: Nate Koenig <natekoenig@gmail.com>
  • Loading branch information
nkoenig authored Jul 24, 2024
1 parent bdaacf5 commit 455cfec
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugins/websocket_server/WebsocketServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,14 @@ void WebsocketServer::Run()

while (this->run)
{
// The second parameter is a timeout that is no longer used by
// libwebsockets.
lws_service(this->context, 0);
// The second parameter is used to control lws's event wait time.
// A -1 does not wait for an event, and 0 causes lws to wait
// for an event. When shutting down the websocket server, the
// wait time could be over 30 seconds if 0 is used.
//
// We are running lws in a separate thread with out our own
// condition variable. So, we will not use lws's event wait.
lws_service(this->context, -1);

// Wait for (1/60) seconds or an event.
std::unique_lock<std::mutex> lock(this->runMutex);
Expand Down

0 comments on commit 455cfec

Please sign in to comment.