mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #6185 from heyitsanthony/wait-time-collision
wait: make WaitTime robust against deadline collisions
This commit is contained in:
commit
961b03420e
@ -43,8 +43,16 @@ func (tl *timeList) Wait(deadline time.Time) <-chan struct{} {
|
||||
tl.l.Lock()
|
||||
defer tl.l.Unlock()
|
||||
ch := make(chan struct{}, 1)
|
||||
// The given deadline SHOULD be unique.
|
||||
tl.m[deadline.UnixNano()] = ch
|
||||
// The given deadline SHOULD be unique but CI manages to get
|
||||
// the same nano time in the unit tests.
|
||||
nano := deadline.UnixNano()
|
||||
for {
|
||||
if tl.m[nano] == nil {
|
||||
tl.m[nano] = ch
|
||||
break
|
||||
}
|
||||
nano++
|
||||
}
|
||||
return ch
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user