From 60b65e206f0c72a987c70e1112b2e12048f15927 Mon Sep 17 00:00:00 2001 From: Chun-Hung Tseng Date: Thu, 16 May 2024 03:30:58 +0800 Subject: [PATCH] Rename mutex within Failpoint from failpointMu to mux Signed-off-by: Chun-Hung Tseng Co-authored-by: Marek Siarkowicz --- runtime/failpoint.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/runtime/failpoint.go b/runtime/failpoint.go index 4bb3d8e..ea8db3f 100644 --- a/runtime/failpoint.go +++ b/runtime/failpoint.go @@ -20,8 +20,8 @@ import ( ) type Failpoint struct { - t *terms - failpointMu sync.RWMutex + t *terms + mux sync.RWMutex } func NewFailpoint(name string) *Failpoint { @@ -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 @@ -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 @@ -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 {