Skip to content

Commit

Permalink
subscriber_statistics_collectors_ should be protected by mutex. (#2592)
Browse files Browse the repository at this point in the history
* subscriber_statistics_collectors_ should be protected by mutex.

Signed-off-by: Tomoya Fujita <[email protected]>

* reduce mutex lock scope.

Signed-off-by: Tomoya Fujita <[email protected]>

---------

Signed-off-by: Tomoya Fujita <[email protected]>
  • Loading branch information
fujitatomoya authored Aug 9, 2024
1 parent ab7cf87 commit 6da8363
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,11 @@ class SubscriptionTopicStatistics
{
auto received_message_age = std::make_unique<ReceivedMessageAge>();
received_message_age->Start();
subscriber_statistics_collectors_.emplace_back(std::move(received_message_age));

auto received_message_period = std::make_unique<ReceivedMessagePeriod>();
received_message_period->Start();
{
std::lock_guard<std::mutex> lock(mutex_);
subscriber_statistics_collectors_.emplace_back(std::move(received_message_age));
subscriber_statistics_collectors_.emplace_back(std::move(received_message_period));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ TEST_F(TestSubscriptionTopicStatisticsFixture, test_receive_stats_for_message_no
uint64_t message_age_count{0};
uint64_t message_period_count{0};

std::set<std::string> received_metrics;
for (const auto & msg : received_messages) {
if (msg.metrics_source == kMessageAgeSourceLabel) {
message_age_count++;
Expand Down

0 comments on commit 6da8363

Please sign in to comment.