Skip to content

Commit

Permalink
Fix a crash in test_message_cache. (#635)
Browse files Browse the repository at this point in the history
The cache consumer requires that you call close()
before calling change_consumer_callback().  The test
forgot the close() call, so was running into a race
where changing out the callback was not atomic.
Remember to call close() in the test, which should fix
some occasional failures in CI.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
  • Loading branch information
clalancette authored Feb 11, 2021
1 parent 2be25a6 commit 5d9afe6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions rosbag2_cpp/test/rosbag2_cpp/test_message_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ TEST_F(MessageCacheTest, message_cache_changing_callback) {
uint32_t counter = 0;
for (uint32_t i = 0; i < message_count; ++i) {
if (counter >= message_count / 2) {
mock_cache_consumer->close();
mock_cache_consumer->change_consume_callback(cb2);
}
auto msg = make_test_msg();
Expand Down

0 comments on commit 5d9afe6

Please sign in to comment.