mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-02-19 12:41:00 +00:00
Fix crash when sending SIGINT before starting the http server
This commit is contained in:
parent
88c3828ad3
commit
a93bad4cf3
@ -154,6 +154,8 @@ int main(int argc, char *argv[]) {
|
||||
stream::rtpThread(shutdown_event);
|
||||
|
||||
httpThread.join();
|
||||
task_pool.stop();
|
||||
task_pool.join();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -846,8 +846,22 @@ void start(std::shared_ptr<safe::signal_t> shutdown_event) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::thread ssl { &https_server_t::accept_and_run, &https_server };
|
||||
std::thread tcp { &http_server_t::accept_and_run, &http_server };
|
||||
auto accept_and_run = [&](auto *http_server) {
|
||||
try {
|
||||
http_server->accept_and_run();
|
||||
} catch(boost::system::system_error &err) {
|
||||
// It's possible the exception gets thrown after calling http_server->stop() from a different thread
|
||||
if(shutdown_event->peek()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BOOST_LOG(fatal) << "Couldn't start http server to ports ["sv << PORT_HTTPS << ", "sv << PORT_HTTP << "]: "sv << err.what();
|
||||
shutdown_event->raise(true);
|
||||
return;
|
||||
}
|
||||
};
|
||||
std::thread ssl { accept_and_run, &https_server };
|
||||
std::thread tcp { accept_and_run, &http_server };
|
||||
|
||||
// Wait for any event
|
||||
shutdown_event->view();
|
||||
|
Loading…
x
Reference in New Issue
Block a user