mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
cluster/zeromq: Call DoTerminate() in destructor
Normal life-cycle is that Terminate() / DoTerminate() is called by zeek-setup code. If that doesn't happen, shutdown and join threads during destructor. try { } catch (...) suggested by Benjamin.
This commit is contained in:
parent
2c6d934ef4
commit
6008e67008
2 changed files with 16 additions and 0 deletions
|
@ -66,6 +66,16 @@ ZeroMQBackend::ZeroMQBackend(std::unique_ptr<EventSerializer> es, std::unique_pt
|
|||
main_inproc = zmq::socket_t(ctx, zmq::socket_type::pair);
|
||||
}
|
||||
|
||||
ZeroMQBackend::~ZeroMQBackend() {
|
||||
try {
|
||||
// DoTerminate is idempotent.
|
||||
DoTerminate();
|
||||
} catch ( ... ) {
|
||||
// This should never happen.
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void ZeroMQBackend::DoInitPostScript() {
|
||||
ThreadedBackend::DoInitPostScript();
|
||||
|
||||
|
@ -109,6 +119,7 @@ void ZeroMQBackend::DoTerminate() {
|
|||
if ( proxy_thread ) {
|
||||
ZEROMQ_DEBUG("Shutting down proxy thread");
|
||||
proxy_thread->Shutdown();
|
||||
proxy_thread.reset();
|
||||
}
|
||||
|
||||
ZEROMQ_DEBUG("Terminated");
|
||||
|
|
|
@ -20,6 +20,11 @@ public:
|
|||
ZeroMQBackend(std::unique_ptr<EventSerializer> es, std::unique_ptr<LogSerializer> ls,
|
||||
std::unique_ptr<detail::EventHandlingStrategy> ehs);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~ZeroMQBackend();
|
||||
|
||||
/**
|
||||
* Spawns a thread running zmq_proxy() for the configured XPUB/XSUB listen
|
||||
* sockets. Only one node in a cluster should do this.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue