Skip to content

Commit

Permalink
libpod API: pull: fix channel race
Browse files Browse the repository at this point in the history
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: containers#8870
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
  • Loading branch information
vrothberg committed Jan 4, 2021
1 parent f261bfc commit acbec39
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/api/handlers/libpod/images_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit acbec39

Please sign in to comment.