Skip to content

Commit 044ee56

Browse files
PetrGuanlalitb
andauthored
Try to fix the potential data race in Statistics (#995)
* Update Statistics.hpp * Remove the usage of m_intervalMs Co-authored-by: Lalit Kumar Bhasin <[email protected]>
1 parent 0653121 commit 044ee56

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lib/stats/Statistics.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ namespace MAT_NS_BEGIN {
2222
m_semanticContextDecorator(m_logManager),
2323
m_isStarted(false)
2424
{
25-
m_intervalMs = m_config.GetMetaStatsSendIntervalSec() * 1000;
2625
}
2726

2827
Statistics::~Statistics()
@@ -35,7 +34,7 @@ namespace MAT_NS_BEGIN {
3534
return;
3635
}
3736

38-
m_intervalMs = m_config.GetMetaStatsSendIntervalSec() * 1000;
37+
unsigned int m_intervalMs = m_config.GetMetaStatsSendIntervalSec() * 1000;
3938
if (m_intervalMs != 0)
4039
{
4140
if (!m_isScheduled.exchange(true))
@@ -54,7 +53,7 @@ namespace MAT_NS_BEGIN {
5453
{
5554
m_isScheduled = false;
5655

57-
m_intervalMs = m_config.GetMetaStatsSendIntervalSec() * 1000;
56+
unsigned int m_intervalMs = m_config.GetMetaStatsSendIntervalSec() * 1000;
5857
if (m_intervalMs == 0)
5958
{
6059
// cancel pending stats event if timer changed at runtime
@@ -90,7 +89,7 @@ namespace MAT_NS_BEGIN {
9089
bool Statistics::handleOnStart()
9190
{
9291
// synchronously send stats event on SDK start, but only if stats are enabled
93-
if (m_intervalMs != 0)
92+
if (m_config.GetMetaStatsSendIntervalSec() * 1000 != 0)
9493
{
9594
send(ACT_STATS_ROLLUP_KIND_START);
9695
}
@@ -108,7 +107,7 @@ namespace MAT_NS_BEGIN {
108107
}
109108

110109
// synchronously send stats event on SDK stop, but only if stats are enabled
111-
if (m_intervalMs != 0)
110+
if (m_config.GetMetaStatsSendIntervalSec() * 1000 != 0)
112111
{
113112
send(ACT_STATS_ROLLUP_KIND_STOP);
114113
}

lib/stats/Statistics.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ namespace MAT_NS_BEGIN {
7373
bool m_isStarted;
7474

7575
std::int64_t m_statEventSentTime;
76-
unsigned m_intervalMs;
7776

7877
public:
7978

0 commit comments

Comments
 (0)