mirror of
https://github.com/minio/minio.git
synced 2025-11-29 05:19:03 -05:00
Fix racy error communication inside go-routine (#6539)
Use CloseWithError to communicate errors in pipe, this PR also fixes potential shadowing of error
This commit is contained in:
committed by
Nitish Tiwari
parent
ce9d36d954
commit
8c29f69b00
@@ -319,11 +319,8 @@ func (c cacheObjects) GetObject(ctx context.Context, bucket, object string, star
|
||||
return err
|
||||
}
|
||||
go func() {
|
||||
if err = GetObjectFn(ctx, bucket, object, 0, objInfo.Size, io.MultiWriter(writer, pipeWriter), etag, opts); err != nil {
|
||||
pipeWriter.CloseWithError(err)
|
||||
return
|
||||
}
|
||||
pipeWriter.Close() // Close writer explicitly signaling we wrote all data.
|
||||
gerr := GetObjectFn(ctx, bucket, object, 0, objInfo.Size, io.MultiWriter(writer, pipeWriter), etag, opts)
|
||||
pipeWriter.CloseWithError(gerr) // Close writer explicitly signaling we wrote all data.
|
||||
}()
|
||||
err = dcache.Put(ctx, bucket, object, hashReader, c.getMetadata(objInfo), opts)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user