gazebosim / gz-transport

Transport library for component communication based on publication/subscription and service calls.
https://gazebosim.org
Apache License 2.0
29 stars 42 forks source link

Fix race condition in TopicInfo #432

Closed caguero closed 1 year ago

caguero commented 1 year ago

🦟 Bug fix

See #430

Summary

This patch fixes a potential race condition when calling TopicList.

See #430 to reproduce the issue/fix with the Gazebo Image Display plugin.

Checklist

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

codecov[bot] commented 1 year ago

Codecov Report

Merging #432 (326cf64) into main (91acfb0) will decrease coverage by 0.04%. The diff coverage is 100.00%.

:exclamation: Current head 326cf64 differs from pull request most recent head e56c132. Consider uploading reports for the commit e56c132 to get more accurate results

@@            Coverage Diff             @@
##             main     #432      +/-   ##
==========================================
- Coverage   87.79%   87.76%   -0.04%     
==========================================
  Files          59       59              
  Lines        5694     5696       +2     
==========================================
  Hits         4999     4999              
- Misses        695      697       +2     
Files Changed Coverage Δ
include/gz/transport/Discovery.hh 87.00% <100.00%> (+0.04%) :arrow_up:

... and 1 file with indirect coverage changes

caguero commented 1 year ago

Do you need to protect also this line ?

this->remoteSubscribers.TopicList(remoteSubs);

There's a mutex after WaitForInit() that protects that line.