mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Broadcaster writer goroutines must only finish when they are caught up
Without this change, there was a narrow race condition that would allow writers to finish when there was still data left to write. This is likely to be what was causing some integration tests to fail with truncated pull output. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
parent
72f355e466
commit
947519bfb3
1 changed files with 7 additions and 3 deletions
|
@ -77,6 +77,12 @@ func (broadcaster *Broadcaster) receiveWrites(observer io.Writer) {
|
||||||
|
|
||||||
broadcaster.Lock()
|
broadcaster.Lock()
|
||||||
|
|
||||||
|
// If we are behind, we need to catch up instead of waiting
|
||||||
|
// or handling a closure.
|
||||||
|
if len(broadcaster.history) != n {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// detect closure of the broadcast writer
|
// detect closure of the broadcast writer
|
||||||
if broadcaster.closed() {
|
if broadcaster.closed() {
|
||||||
broadcaster.Unlock()
|
broadcaster.Unlock()
|
||||||
|
@ -84,9 +90,7 @@ func (broadcaster *Broadcaster) receiveWrites(observer io.Writer) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(broadcaster.history) == n {
|
|
||||||
broadcaster.cond.Wait()
|
broadcaster.cond.Wait()
|
||||||
}
|
|
||||||
|
|
||||||
// Mutex is still locked as the loop continues
|
// Mutex is still locked as the loop continues
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue