Merge pull request #770 from noxiouz/fix_leak_in_push
[Client] Fix possible goroutine leak in push.
This commit is contained in:
commit
5829d8fa6c
1 changed files with 7 additions and 1 deletions
|
@ -36,6 +36,8 @@ func Push(c Client, objectStore ObjectStore, name, tag string) error {
|
||||||
errChans[i] = make(chan error)
|
errChans[i] = make(chan error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cancelCh := make(chan struct{})
|
||||||
|
|
||||||
// Iterate over each layer in the manifest, simultaneously pushing no more
|
// Iterate over each layer in the manifest, simultaneously pushing no more
|
||||||
// than simultaneousLayerPushWindow layers at a time. If an error is
|
// than simultaneousLayerPushWindow layers at a time. If an error is
|
||||||
// received from a layer push, we abort the push.
|
// received from a layer push, we abort the push.
|
||||||
|
@ -45,13 +47,17 @@ func Push(c Client, objectStore ObjectStore, name, tag string) error {
|
||||||
err := <-errChans[dependentLayer]
|
err := <-errChans[dependentLayer]
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithField("error", err).Warn("Push aborted")
|
log.WithField("error", err).Warn("Push aborted")
|
||||||
|
close(cancelCh)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if i < len(manifest.FSLayers) {
|
if i < len(manifest.FSLayers) {
|
||||||
go func(i int) {
|
go func(i int) {
|
||||||
errChans[i] <- pushLayer(c, objectStore, name, manifest.FSLayers[i])
|
select {
|
||||||
|
case errChans[i] <- pushLayer(c, objectStore, name, manifest.FSLayers[i]):
|
||||||
|
case <-cancelCh: // recv broadcast notification about cancelation
|
||||||
|
}
|
||||||
}(i)
|
}(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue