update k8s.io/utils to fix keymutex issues

This commit is contained in:
danielqsj
2019-02-21 07:06:56 -07:00
parent 7b203c6809
commit b5dfa49e32
4 changed files with 20 additions and 17 deletions

View File

@@ -42,17 +42,17 @@ type hashedKeyMutex struct {
// Acquires a lock associated with the specified ID.
func (km *hashedKeyMutex) LockKey(id string) {
km.mutexes[km.hash(id)%len(km.mutexes)].Lock()
km.mutexes[km.hash(id)%uint32(len(km.mutexes))].Lock()
}
// Releases the lock associated with the specified ID.
func (km *hashedKeyMutex) UnlockKey(id string) error {
km.mutexes[km.hash(id)%len(km.mutexes)].Unlock()
km.mutexes[km.hash(id)%uint32(len(km.mutexes))].Unlock()
return nil
}
func (km *hashedKeyMutex) hash(id string) int {
func (km *hashedKeyMutex) hash(id string) uint32 {
h := fnv.New32a()
h.Write([]byte(id))
return int(h.Sum32())
return h.Sum32()
}