Skip to content

Commit

Permalink
log: modify lock defer unlock order in sync handler (#24667)
Browse files Browse the repository at this point in the history
This modifies the order of Lock() defer Unlock() to follow the more
typically used pattern.
  • Loading branch information
aaronbuchwald authored Apr 8, 2022
1 parent c1b69bd commit 6c3fea0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion log/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ func StreamHandler(wr io.Writer, fmtr Format) Handler {
func SyncHandler(h Handler) Handler {
var mu sync.Mutex
return FuncHandler(func(r *Record) error {
defer mu.Unlock()
mu.Lock()
defer mu.Unlock()

return h.Log(r)
})
}
Expand Down

0 comments on commit 6c3fea0

Please sign in to comment.