mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
cluster/zeromq: Handle EINTR at shutdown
Read ::signal_val and early exit a DoPublish() in case termination happened while blocked in inproc.send()
This commit is contained in:
parent
94ec3af2b0
commit
540d9da5ef
1 changed files with 17 additions and 1 deletions
|
@ -25,6 +25,8 @@
|
||||||
#include "zeek/cluster/backend/zeromq/ZeroMQ-Proxy.h"
|
#include "zeek/cluster/backend/zeromq/ZeroMQ-Proxy.h"
|
||||||
#include "zeek/util.h"
|
#include "zeek/util.h"
|
||||||
|
|
||||||
|
extern int signal_val;
|
||||||
|
|
||||||
namespace zeek {
|
namespace zeek {
|
||||||
|
|
||||||
namespace plugin::Zeek_Cluster_Backend_ZeroMQ {
|
namespace plugin::Zeek_Cluster_Backend_ZeroMQ {
|
||||||
|
@ -266,7 +268,21 @@ bool ZeroMQBackend::DoPublishEvent(const std::string& topic, const std::string&
|
||||||
// This should never fail, it will instead block
|
// This should never fail, it will instead block
|
||||||
// when HWM is reached. I guess we need to see if
|
// when HWM is reached. I guess we need to see if
|
||||||
// and how this can happen :-/
|
// and how this can happen :-/
|
||||||
|
try {
|
||||||
main_inproc.send(parts[i], flags);
|
main_inproc.send(parts[i], flags);
|
||||||
|
} catch ( zmq::error_t& err ) {
|
||||||
|
// If send() was interrupted and Zeek caught an interrupt or term signal,
|
||||||
|
// fail the publish as we're about to shutdown. There's nothing the user
|
||||||
|
// can do, but it indicates an overload situation as send() was blocking.
|
||||||
|
if ( err.num() == EINTR && (signal_val == SIGINT || signal_val == SIGTERM) ) {
|
||||||
|
zeek::reporter->Error("Failed publish() using ZeroMQ backend at shutdown: %s (signal_val=%d)",
|
||||||
|
err.what(), signal_val);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
zeek::reporter->Error("Unexpected ZeroMQ::DoPublishEvent() error: %s", err.what());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue