Skip to content

Commit

Permalink
Unlock memguard global change mutex only when locked (#5714)
Browse files Browse the repository at this point in the history
  • Loading branch information
dany74q authored Oct 14, 2024
1 parent 3f0de96 commit 888a732
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/protocols/common/protocolstate/memguardian.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ var muGlobalChange sync.Mutex

// Global setting
func GlobalGuardBytesBufferAlloc() error {
if muGlobalChange.TryLock() {
if !muGlobalChange.TryLock() {
return nil

}
defer muGlobalChange.Unlock()

Expand All @@ -95,9 +94,8 @@ func GlobalGuardBytesBufferAlloc() error {

// Global setting
func GlobalRestoreBytesBufferAlloc() {
if muGlobalChange.TryLock() {
if !muGlobalChange.TryLock() {
return

}
defer muGlobalChange.Unlock()

Expand Down

0 comments on commit 888a732

Please sign in to comment.