Check to see why a lock acquisition failed
This commit is contained in:
parent
7e82b3c32c
commit
0184227828
20
api/lock.go
20
api/lock.go
|
@ -183,11 +183,23 @@ WAIT:
|
||||||
|
|
||||||
// Handle the case of not getting the lock
|
// Handle the case of not getting the lock
|
||||||
if !locked {
|
if !locked {
|
||||||
select {
|
// Determine why the lock failed
|
||||||
case <-time.After(DefaultLockRetryTime):
|
qOpts.WaitIndex = 0
|
||||||
|
pair, meta, err = kv.Get(l.opts.Key, qOpts)
|
||||||
|
if pair != nil && pair.Session != "" {
|
||||||
|
//If the session is not null, this means that a wait can safely happen
|
||||||
|
//using a long poll
|
||||||
|
qOpts.WaitIndex = meta.LastIndex
|
||||||
goto WAIT
|
goto WAIT
|
||||||
case <-stopCh:
|
} else {
|
||||||
return nil, nil
|
// If the session is empty and the lock failed to acquire, then it means
|
||||||
|
// a lock-delay is in effect and a timed wait must be used
|
||||||
|
select {
|
||||||
|
case <-time.After(DefaultLockRetryTime):
|
||||||
|
goto WAIT
|
||||||
|
case <-stopCh:
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue