Skip to content

Commit 4660f63

Browse files
committed
copy: remove wrapping io.NopCloser from push writer pipe
io.Pipe produces a PipeReader and a PipeWriter - a close on the write side, causes an error on both the read and write sides, while a close on the read side causes an error on only the read side. Previously, we explicitly prohibited closing from the read side. However, http.Request.Body requires that "calling Close should unblock a Read waiting for input". Our reader will not do this - calling close becomes a no-op. This can cause a deadlock because client.Do may never terminate in some circumstances. We need the Reader side to close its side of the pipe as well, which it already does using the go standard library - otherwise, we can hang forever, writing to a pipe that will never be closed. Allowing the requester to close the body should be safe - we never reuse the same reader between requests, as the result of body() will never be reused by the guarantees of the standard library. Signed-off-by: Justin Chadwell <[email protected]>
1 parent 96bf529 commit 4660f63

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/remotes/docker/pusher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func (p dockerPusher) push(ctx context.Context, desc ocispec.Descriptor, ref str
280280
req.body = func() (io.ReadCloser, error) {
281281
pr, pw := io.Pipe()
282282
pushw.setPipe(pw)
283-
return io.NopCloser(pr), nil
283+
return pr, nil
284284
}
285285
req.size = desc.Size
286286

0 commit comments

Comments
 (0)