mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 13:08:20 +00:00
cluster/zeromq: Short-circuit DoPublishLogWrite() when not initialized
After moving the log_push initialization from the constructor to the DoInit() method, it's now possible that DoPublishLogWrites() is invoked even if DoInit() was never called. Handle this by short-circuiting. This is sort of an error, but can happen during tests if scripts are loaded somewhat arbitrarily.
This commit is contained in:
parent
89c0b0faf3
commit
1afd497c0c
1 changed files with 8 additions and 1 deletions
|
@ -373,7 +373,6 @@ bool ZeroMQBackend::DoUnsubscribe(const std::string& topic_prefix) {
|
||||||
|
|
||||||
bool ZeroMQBackend::DoPublishLogWrites(const logging::detail::LogWriteHeader& header, const std::string& format,
|
bool ZeroMQBackend::DoPublishLogWrites(const logging::detail::LogWriteHeader& header, const std::string& format,
|
||||||
byte_buffer& buf) {
|
byte_buffer& buf) {
|
||||||
ZEROMQ_DEBUG("Publishing %zu bytes of log writes (path %s)", buf.size(), header.path.c_str());
|
|
||||||
static std::string message_type = "log-write";
|
static std::string message_type = "log-write";
|
||||||
|
|
||||||
// Publishing a log write is done using 4 parts
|
// Publishing a log write is done using 4 parts
|
||||||
|
@ -389,6 +388,14 @@ bool ZeroMQBackend::DoPublishLogWrites(const logging::detail::LogWriteHeader& he
|
||||||
zmq::const_buffer{buf.data(), buf.size()},
|
zmq::const_buffer{buf.data(), buf.size()},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If the log_push socket isn't yet initialized or has been closed, just return.
|
||||||
|
if ( ! log_push ) {
|
||||||
|
ZEROMQ_DEBUG("Skipping log write - log_push socket not open");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZEROMQ_DEBUG("Publishing %zu bytes of log writes (path %s)", buf.size(), header.path.c_str());
|
||||||
|
|
||||||
for ( size_t i = 0; i < parts.size(); i++ ) {
|
for ( size_t i = 0; i < parts.size(); i++ ) {
|
||||||
zmq::send_flags flags = zmq::send_flags::dontwait;
|
zmq::send_flags flags = zmq::send_flags::dontwait;
|
||||||
if ( i < parts.size() - 1 )
|
if ( i < parts.size() - 1 )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue