libpod API: pull: fix channel race

Fix a race condition in the pull endpoint caused by buffered channels.
Using buffered channels can lead to the context's cancel function to be
executed prior to the items being read from the channel.

Fixes: #8870
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2021-01-04 17:46:24 +01:00
parent f261bfc549
commit acbec396fd

View File

@ -115,10 +115,10 @@ func ImagesPull(w http.ResponseWriter, r *http.Request) {
}
}
writer := channel.NewWriter(make(chan []byte, 1))
writer := channel.NewWriter(make(chan []byte))
defer writer.Close()
stderr := channel.NewWriter(make(chan []byte, 1))
stderr := channel.NewWriter(make(chan []byte))
defer stderr.Close()
images := make([]string, 0, len(imagesToPull))