diff --git a/pkg/util/goroutinemap/goroutinemap.go b/pkg/util/goroutinemap/goroutinemap.go index 202634f15b9..c5f6884a0c9 100644 --- a/pkg/util/goroutinemap/goroutinemap.go +++ b/pkg/util/goroutinemap/goroutinemap.go @@ -36,11 +36,11 @@ const ( // that GoRoutineMap will refuse to allow another operation to start with // the same operation name (if exponentialBackOffOnError is enabled). Each // successive error results in a wait 2x times the previous. - initialDurationBeforeRetry time.Duration = 500 * time.Millisecond + initialDurationBeforeRetry = 500 * time.Millisecond // maxDurationBeforeRetry is the maximum amount of time that // durationBeforeRetry will grow to due to exponential backoff. - maxDurationBeforeRetry time.Duration = 2 * time.Minute + maxDurationBeforeRetry = 2 * time.Minute ) // GoRoutineMap defines the supported set of operations. @@ -65,10 +65,9 @@ func NewGoRoutineMap(exponentialBackOffOnError bool) GoRoutineMap { g := &goRoutineMap{ operations: make(map[string]operation), exponentialBackOffOnError: exponentialBackOffOnError, - lock: &sync.Mutex{}, } - g.cond = sync.NewCond(g.lock) + g.cond = sync.NewCond(&g.lock) return g } @@ -76,7 +75,7 @@ type goRoutineMap struct { operations map[string]operation exponentialBackOffOnError bool cond *sync.Cond - lock *sync.Mutex + lock sync.Mutex } type operation struct { diff --git a/pkg/volume/util/nestedpendingoperations/nestedpendingoperations.go b/pkg/volume/util/nestedpendingoperations/nestedpendingoperations.go index 4aaddf299e8..9b3743f7bf5 100644 --- a/pkg/volume/util/nestedpendingoperations/nestedpendingoperations.go +++ b/pkg/volume/util/nestedpendingoperations/nestedpendingoperations.go @@ -65,9 +65,8 @@ func NewNestedPendingOperations(exponentialBackOffOnError bool) NestedPendingOpe g := &nestedPendingOperations{ operations: []operation{}, exponentialBackOffOnError: exponentialBackOffOnError, - lock: &sync.Mutex{}, } - g.cond = sync.NewCond(g.lock) + g.cond = sync.NewCond(&g.lock) return g } @@ -75,7 +74,7 @@ type nestedPendingOperations struct { operations []operation exponentialBackOffOnError bool cond *sync.Cond - lock *sync.Mutex + lock sync.Mutex } type operation struct {