mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-10 23:01:45 +02:00
Fix deadlock during shutdown
This commit is contained in:
parent
e195298e74
commit
87d4c00d21
1 changed files with 9 additions and 6 deletions
|
@ -25,7 +25,6 @@
|
||||||
#include "common/daemon.hpp"
|
#include "common/daemon.hpp"
|
||||||
#endif
|
#endif
|
||||||
#include "common/sample_format.hpp"
|
#include "common/sample_format.hpp"
|
||||||
#include "common/signal_handler.hpp"
|
|
||||||
#include "common/snap_exception.hpp"
|
#include "common/snap_exception.hpp"
|
||||||
#include "common/time_defs.hpp"
|
#include "common/time_defs.hpp"
|
||||||
#include "common/utils/string_utils.hpp"
|
#include "common/utils/string_utils.hpp"
|
||||||
|
@ -274,9 +273,13 @@ int main(int argc, char* argv[])
|
||||||
num_threads = std::max(2, std::min(4, static_cast<int>(std::thread::hardware_concurrency())));
|
num_threads = std::max(2, std::min(4, static_cast<int>(std::thread::hardware_concurrency())));
|
||||||
LOG(INFO) << "number of threads: " << num_threads << ", hw threads: " << std::thread::hardware_concurrency() << "\n";
|
LOG(INFO) << "number of threads: " << num_threads << ", hw threads: " << std::thread::hardware_concurrency() << "\n";
|
||||||
|
|
||||||
auto sig = install_signal_handler({SIGHUP, SIGTERM, SIGINT},
|
// Construct a signal set registered for process termination.
|
||||||
[&io_context](int signal, const std::string& name) {
|
boost::asio::signal_set signals(io_context, SIGHUP, SIGINT, SIGTERM);
|
||||||
SLOG(INFO) << "Received signal " << signal << ": " << name << "\n";
|
signals.async_wait([&io_context](const boost::system::error_code& ec, int signal) {
|
||||||
|
if (!ec)
|
||||||
|
SLOG(INFO) << "Received signal " << signal << ": " << strsignal(signal) << "\n";
|
||||||
|
else
|
||||||
|
SLOG(INFO) << "Failed to wait for signal: " << ec << "\n";
|
||||||
io_context.stop();
|
io_context.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue