mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Mark MsgThread::cnt_sent_{in,out} as atomic to avoid a data race
This commit is contained in:
parent
a2ab1b1484
commit
4dc20826fd
2 changed files with 9 additions and 5 deletions
|
@ -202,7 +202,9 @@ Message::~Message()
|
||||||
|
|
||||||
MsgThread::MsgThread() : BasicThread(), queue_in(this, nullptr), queue_out(nullptr, this)
|
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;
|
main_finished = false;
|
||||||
child_finished = false;
|
child_finished = false;
|
||||||
child_sent_finish = false;
|
child_sent_finish = false;
|
||||||
|
@ -457,8 +459,8 @@ void MsgThread::Run()
|
||||||
|
|
||||||
void MsgThread::GetStats(Stats* stats)
|
void MsgThread::GetStats(Stats* stats)
|
||||||
{
|
{
|
||||||
stats->sent_in = cnt_sent_in;
|
stats->sent_in = cnt_sent_in.load();
|
||||||
stats->sent_out = cnt_sent_out;
|
stats->sent_out = cnt_sent_out.load();
|
||||||
stats->pending_in = queue_in.Size();
|
stats->pending_in = queue_in.Size();
|
||||||
stats->pending_out = queue_out.Size();
|
stats->pending_out = queue_out.Size();
|
||||||
queue_in.GetStats(&stats->queue_in_stats);
|
queue_in.GetStats(&stats->queue_in_stats);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
#include "zeek/DebugLogger.h"
|
#include "zeek/DebugLogger.h"
|
||||||
#include "zeek/threading/BasicThread.h"
|
#include "zeek/threading/BasicThread.h"
|
||||||
#include "zeek/threading/Queue.h"
|
#include "zeek/threading/Queue.h"
|
||||||
|
@ -335,8 +337,8 @@ private:
|
||||||
Queue<BasicInputMessage *> queue_in;
|
Queue<BasicInputMessage *> queue_in;
|
||||||
Queue<BasicOutputMessage *> queue_out;
|
Queue<BasicOutputMessage *> queue_out;
|
||||||
|
|
||||||
uint64_t cnt_sent_in; // Counts message sent to child.
|
std::atomic<uint64_t> cnt_sent_in; // Counts message sent to child.
|
||||||
uint64_t cnt_sent_out; // Counts message sent by child.
|
std::atomic<uint64_t> cnt_sent_out; // Counts message sent by child.
|
||||||
|
|
||||||
bool main_finished; // Main thread is finished, meaning child_finished propagated back through message queue.
|
bool main_finished; // Main thread is finished, meaning child_finished propagated back through message queue.
|
||||||
bool child_finished; // Child thread is finished.
|
bool child_finished; // Child thread is finished.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue