Repository navigation
fix: loggingStream mutex unlock - #64
Open
Jiang-Gianni wants to merge 1 commit into
Open
Jiang-Gianni wants to merge 1 commit into
Jiang-Gianni wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the logCommon method in log.go to use a deferred unlock (defer s.logMu.Unlock()) immediately after acquiring the lock, replacing the manual unlock at the end of the function. This ensures the mutex is safely unlocked even if the function exits early. There are no review comments, and I have no additional feedback to provide.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #64 +/- ##
=======================================
- Coverage 85.2% 85.2% -0.1%
=======================================
Files 27 27
Lines 6135 6134 -1
=======================================
- Hits 5230 5229 -1
Misses 905 905
|
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.
Found this issue while using the logging stream.
In the
case *jsonrpc2.Response:branch with an error in the message: theloggingStreammutex is not unlocked before thereturn, blocking any next call tologCommonRather than duplicating the mutex
Unlockfunction call beforereturnit is more idiomatic to usedeferright after locking the mutex