Skip to content

Commit 29726ba

Browse files
committed
fix(issue-215): more strict locking (to see where it does break)
1 parent 42203d3 commit 29726ba

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

api/v1/registry/client/cache/cache.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (t *token) Exists(key string) bool {
2929
_, defined := t.items[key]
3030

3131
if !defined && WaitBetween != 0 {
32-
log.Debugf("Locking token operations for %v (key: %s)", WaitBetween, key)
32+
log.Debugf("[EXISTS] Locking token operations for %v (key: %s)", WaitBetween, key)
3333
time.Sleep(WaitBetween)
3434
}
3535

@@ -38,6 +38,14 @@ func (t *token) Exists(key string) bool {
3838

3939
// Get gets token for a passed key
4040
func (t *token) Get(key string) auth.Token {
41+
t.mux.Lock()
42+
defer t.mux.Unlock()
43+
44+
if WaitBetween != 0 {
45+
log.Debugf("[GET] Locking token operations for %v (key: %s)", WaitBetween, key)
46+
time.Sleep(WaitBetween)
47+
}
48+
4149
return t.items[key]
4250
}
4351

0 commit comments

Comments
 (0)