Mark MsgThread::cnt_sent_{in,out} as atomic to avoid a data race

This commit is contained in:
Tim Wojtulewicz 2021-08-09 10:39:56 -07:00
parent a2ab1b1484
commit 4dc20826fd
2 changed files with 9 additions and 5 deletions

View file

@ -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);