Skip to content

Commit

Permalink
Merge pull request #10244 from dmcgowan/registry-panic-fix
Browse files Browse the repository at this point in the history
Fix write after close on http response
  • Loading branch information
Arnaud Porterie committed Jan 22, 2015
2 parents 4aa60a9 + 4e4a5b2 commit ef33efc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions engine/streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func (o *Output) Close() error {
}
}
o.tasks.Wait()
o.dests = nil
return firstErr
}

Expand Down
11 changes: 9 additions & 2 deletions graph/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ func (s *TagStore) pushImage(r *registry.Session, out io.Writer, imgID, ep strin
// Send the layer
log.Debugf("rendered layer for %s of [%d] size", imgData.ID, layerData.Size)

checksum, checksumPayload, err := r.PushImageLayerRegistry(imgData.ID, utils.ProgressReader(layerData, int(layerData.Size), out, sf, false, utils.TruncateID(imgData.ID), "Pushing"), ep, token, jsonRaw)
prgRd := utils.ProgressReader(layerData, int(layerData.Size), out, sf, false, utils.TruncateID(imgData.ID), "Pushing")
defer prgRd.Close()

checksum, checksumPayload, err := r.PushImageLayerRegistry(imgData.ID, prgRd, ep, token, jsonRaw)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -338,8 +341,12 @@ func (s *TagStore) pushV2Repository(r *registry.Session, eng *engine.Engine, out
out.Write(sf.FormatProgress(utils.TruncateID(img.ID), "Image push failed", nil))
return err
}

if !exists {
err = r.PutV2ImageBlob(endpoint, repoInfo.RemoteName, sumParts[0], manifestSum, utils.ProgressReader(arch, int(img.Size), out, sf, false, utils.TruncateID(img.ID), "Pushing"), auth)
prgRd := utils.ProgressReader(arch, int(img.Size), out, sf, false, utils.TruncateID(img.ID), "Pushing")
defer prgRd.Close()

err = r.PutV2ImageBlob(endpoint, repoInfo.RemoteName, sumParts[0], manifestSum, prgRd, auth)
if err != nil {
out.Write(sf.FormatProgress(utils.TruncateID(img.ID), "Image push failed", nil))
return err
Expand Down
2 changes: 1 addition & 1 deletion registry/session_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (r *Session) PutV2ImageBlob(ep *Endpoint, imageName, sumType, sumStr string

method := "PUT"
log.Debugf("[registry] Calling %q %s", method, location)
req, err = r.reqFactory.NewRequest(method, location, blobRdr)
req, err = r.reqFactory.NewRequest(method, location, ioutil.NopCloser(blobRdr))
if err != nil {
return err
}
Expand Down

0 comments on commit ef33efc

Please sign in to comment.