Fix concurrent-safe route registration (data race in addRoute/Routes)#4524
Open
mehrdadbn9 wants to merge 5 commits intogin-gonic:masterfrom
Open
Fix concurrent-safe route registration (data race in addRoute/Routes)#4524mehrdadbn9 wants to merge 5 commits intogin-gonic:masterfrom
mehrdadbn9 wants to merge 5 commits intogin-gonic:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4524 +/- ##
==========================================
+ Coverage 99.21% 99.27% +0.06%
==========================================
Files 42 46 +4
Lines 3182 3042 -140
==========================================
- Hits 3157 3020 -137
+ Misses 17 15 -2
+ Partials 8 7 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ad9a991 to
3af7291
Compare
Author
|
"Hi maintainers! 👋 All CI checks are now passing:
|
11248ab to
718ce2f
Compare
- Add sync.RWMutex to Engine struct for thread-safe access - Protect addRoute() with Lock() for exclusive write access - Protect Routes() with RLock() for concurrent read access - Add concurrent test to verify no data race - Add tests for serveError function coverage Fixes gin-gonic#4457
5c399c1 to
edff091
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a data race between `addRoute()` and `Routes()` functions where one goroutine appends to `trees` slice while another reads from it.
Root Cause:
Solution:
Testing:
Related Code:
Fixes: #4457