Avoid deadlock in unpacker.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2019-11-13 14:22:35 -08:00
parent a176179a08
commit c560591627
2 changed files with 44 additions and 3 deletions

View File

@@ -70,6 +70,11 @@ func (c *Client) Pull(ctx context.Context, ref string, opts ...RemoteOpt) (_ Ima
}
unpackWrapper, eg := u.handlerWrapper(ctx, &unpacks)
defer func() {
if retErr != nil {
// Forcibly stop the unpacker if there is
// an error.
eg.Cancel()
}
if err := eg.Wait(); err != nil {
if retErr == nil {
retErr = errors.Wrap(err, "unpack")