mirror of
https://github.com/containers/skopeo.git
synced 2026-05-04 10:22:34 +00:00
Use WaitGroup.Go
Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
@@ -332,7 +332,6 @@ func (h *proxyHandler) allocPipe() (*os.File, *activePipe, error) {
|
||||
w: pipew,
|
||||
}
|
||||
h.activePipes[uint32(pipew.Fd())] = &f
|
||||
f.wg.Add(1)
|
||||
return piper, &f, nil
|
||||
}
|
||||
|
||||
@@ -345,14 +344,12 @@ func (h *proxyHandler) returnBytes(retval any, buf []byte) (replyBuf, error) {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
go func() {
|
||||
// Signal completion when we return
|
||||
defer f.wg.Done()
|
||||
f.wg.Go(func() {
|
||||
_, err = io.Copy(f.w, bytes.NewReader(buf))
|
||||
if err != nil {
|
||||
f.err = err
|
||||
}
|
||||
}()
|
||||
})
|
||||
|
||||
ret.value = retval
|
||||
ret.fd = piper
|
||||
@@ -583,10 +580,8 @@ func (h *proxyHandler) GetBlob(args []any) (replyBuf, error) {
|
||||
blobr.Close()
|
||||
return ret, err
|
||||
}
|
||||
go func() {
|
||||
// Signal completion when we return
|
||||
f.wg.Go(func() {
|
||||
defer blobr.Close()
|
||||
defer f.wg.Done()
|
||||
verifier := d.Verifier()
|
||||
tr := io.TeeReader(blobr, verifier)
|
||||
n, err := io.Copy(f.w, tr)
|
||||
@@ -600,7 +595,7 @@ func (h *proxyHandler) GetBlob(args []any) (replyBuf, error) {
|
||||
if !verifier.Verified() {
|
||||
f.err = fmt.Errorf("corrupted blob, expecting %s", d.String())
|
||||
}
|
||||
}()
|
||||
})
|
||||
|
||||
ret.value = blobSize
|
||||
ret.fd = piper
|
||||
|
||||
@@ -214,9 +214,7 @@ func (p *proxy) callGetRawBlob(args []any) (rval any, buf []byte, err error) {
|
||||
var wg sync.WaitGroup
|
||||
fetchchan := make(chan byteFetch, 1)
|
||||
errchan := make(chan proxyError, 1)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
wg.Go(func() {
|
||||
defer close(fetchchan)
|
||||
defer fd.datafd.Close()
|
||||
buf, err := io.ReadAll(fd.datafd)
|
||||
@@ -224,10 +222,8 @@ func (p *proxy) callGetRawBlob(args []any) (rval any, buf []byte, err error) {
|
||||
content: buf,
|
||||
err: err,
|
||||
}
|
||||
}()
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
})
|
||||
wg.Go(func() {
|
||||
defer fd.errfd.Close()
|
||||
defer close(errchan)
|
||||
buf, err := io.ReadAll(fd.errfd)
|
||||
@@ -248,7 +244,7 @@ func (p *proxy) callGetRawBlob(args []any) (rval any, buf []byte, err error) {
|
||||
panic(unmarshalErr)
|
||||
}
|
||||
errchan <- proxyErr
|
||||
}()
|
||||
})
|
||||
wg.Wait()
|
||||
|
||||
errMsg := <-errchan
|
||||
|
||||
Reference in New Issue
Block a user