diff --git a/src/threading/MsgThread.cc b/src/threading/MsgThread.cc index 0bc3fa3901..87b4cf5677 100644 --- a/src/threading/MsgThread.cc +++ b/src/threading/MsgThread.cc @@ -202,7 +202,9 @@ Message::~Message() MsgThread::MsgThread() : BasicThread(), queue_in(this, nullptr), queue_out(nullptr, this) { - cnt_sent_in = cnt_sent_out = 0; + cnt_sent_in.store(0); + cnt_sent_out.store(0); + main_finished = false; child_finished = false; child_sent_finish = false; @@ -457,8 +459,8 @@ void MsgThread::Run() void MsgThread::GetStats(Stats* stats) { - stats->sent_in = cnt_sent_in; - stats->sent_out = cnt_sent_out; + stats->sent_in = cnt_sent_in.load(); + stats->sent_out = cnt_sent_out.load(); stats->pending_in = queue_in.Size(); stats->pending_out = queue_out.Size(); queue_in.GetStats(&stats->queue_in_stats); diff --git a/src/threading/MsgThread.h b/src/threading/MsgThread.h index 155fbb6ae4..5ab5b60ddd 100644 --- a/src/threading/MsgThread.h +++ b/src/threading/MsgThread.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "zeek/DebugLogger.h" #include "zeek/threading/BasicThread.h" #include "zeek/threading/Queue.h" @@ -335,8 +337,8 @@ private: Queue queue_in; Queue queue_out; - uint64_t cnt_sent_in; // Counts message sent to child. - uint64_t cnt_sent_out; // Counts message sent by child. + std::atomic cnt_sent_in; // Counts message sent to child. + std::atomic cnt_sent_out; // Counts message sent by child. bool main_finished; // Main thread is finished, meaning child_finished propagated back through message queue. bool child_finished; // Child thread is finished.