datarhei / gosrt

Implementation of the SRT protocol in pure Go
https://datarhei.com
MIT License
114 stars 17 forks source link

fix race condition in liveReceive.Stats() and liveSend.Stats() #26

Closed aler9 closed 1 year ago

aler9 commented 1 year ago

When Conn.Stats() is called, liveSend.Stats() and liveReceive.Stats() are also called. They both write to live*.statistics while it is also read and written in parallel by tick routines.

This patch fixes the issue by protecting live*.statistics with the existing mutex.

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 66.66% and project coverage change: -0.20% :warning:

Comparison is base (da138d1) 65.15% compared to head (6f9624a) 64.95%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #26 +/- ## ========================================== - Coverage 65.15% 64.95% -0.20% ========================================== Files 14 14 Lines 4560 4560 ========================================== - Hits 2971 2962 -9 - Misses 1319 1326 +7 - Partials 270 272 +2 ``` | Flag | Coverage Δ | | |---|---|---| | unit-linux | `64.95% <66.66%> (-0.20%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=datarhei#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files Changed](https://app.codecov.io/gh/datarhei/gosrt/pull/26?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=datarhei) | Coverage Δ | | |---|---|---| | [internal/congestion/live.go](https://app.codecov.io/gh/datarhei/gosrt/pull/26?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=datarhei#diff-aW50ZXJuYWwvY29uZ2VzdGlvbi9saXZlLmdv) | `66.25% <66.66%> (ø)` | | ... and [3 files with indirect coverage changes](https://app.codecov.io/gh/datarhei/gosrt/pull/26/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=datarhei)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.