Merge pull request #4281 from filecoin-project/steb/seal-race

fix race in unseal
This commit is contained in:
Łukasz Magiera 2020-10-10 02:23:02 +02:00 committed by GitHub
commit 114a1aaffd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -290,10 +290,6 @@ func (sb *Sealer) UnsealPiece(ctx context.Context, sector abi.SectorID, offset s
defer opr.Close() // nolint defer opr.Close() // nolint
padwriter := fr32.NewPadWriter(out) padwriter := fr32.NewPadWriter(out)
if err != nil {
perr = xerrors.Errorf("creating new padded writer: %w", err)
return
}
bsize := uint64(size.Padded()) bsize := uint64(size.Padded())
if bsize > uint64(runtime.NumCPU())*fr32.MTTresh { if bsize > uint64(runtime.NumCPU())*fr32.MTTresh {
@ -302,7 +298,7 @@ func (sb *Sealer) UnsealPiece(ctx context.Context, sector abi.SectorID, offset s
bw := bufio.NewWriterSize(padwriter, int(abi.PaddedPieceSize(bsize).Unpadded())) bw := bufio.NewWriterSize(padwriter, int(abi.PaddedPieceSize(bsize).Unpadded()))
_, err = io.CopyN(bw, opr, int64(size)) _, err := io.CopyN(bw, opr, int64(size))
if err != nil { if err != nil {
perr = xerrors.Errorf("copying data: %w", err) perr = xerrors.Errorf("copying data: %w", err)
return return