Skip to content

Commit

Permalink
Rename mutex within Failpoint from failpointMu to mux
Browse files Browse the repository at this point in the history
Signed-off-by: Chun-Hung Tseng <[email protected]>
Co-authored-by: Marek Siarkowicz <[email protected]>
  • Loading branch information
henrybear327 and serathius committed May 15, 2024
1 parent 499c363 commit 60b65e2
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions runtime/failpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
)

type Failpoint struct {
t *terms
failpointMu sync.RWMutex
t *terms
mux sync.RWMutex
}

func NewFailpoint(name string) *Failpoint {
Expand All @@ -34,10 +34,10 @@ func NewFailpoint(name string) *Failpoint {
// Notice that during the exection of Acquire(), the failpoint can be disabled,
// but the already in-flight execution won't be terminated
func (fp *Failpoint) Acquire() (interface{}, error) {
fp.failpointMu.RLock()
fp.mux.RLock()
// terms are locked during execution, so deepcopy is not required as no change can be made during execution
cachedT := fp.t
fp.failpointMu.RUnlock()
fp.mux.RUnlock()

if cachedT == nil {
return nil, ErrDisabled
Expand All @@ -55,15 +55,15 @@ func (fp *Failpoint) BadType(v interface{}, t string) {
}

func (fp *Failpoint) SetTerm(t *terms) {
fp.failpointMu.Lock()
defer fp.failpointMu.Unlock()
fp.mux.Lock()
defer fp.mux.Unlock()

fp.t = t
}

func (fp *Failpoint) ClearTerm() error {
fp.failpointMu.Lock()
defer fp.failpointMu.Unlock()
fp.mux.Lock()
defer fp.mux.Unlock()

if fp.t == nil {
return ErrDisabled
Expand All @@ -74,8 +74,8 @@ func (fp *Failpoint) ClearTerm() error {
}

func (fp *Failpoint) Status() (string, int, error) {
fp.failpointMu.RLock()
defer fp.failpointMu.RUnlock()
fp.mux.RLock()
defer fp.mux.RUnlock()

t := fp.t
if t == nil {
Expand Down

0 comments on commit 60b65e2

Please sign in to comment.