From 83dfc460d490721dafa237717c96c8918cf1262e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 9 Oct 2020 15:39:41 -0700 Subject: [PATCH] fix race in unseal 1. Remove an invalid error check. 2. Make sure to shadow the outer error type from within the goroutine instead or reading the outer type. This may have been causing test issues (caught in TestMinerAllInfo with the race detector). --- extern/sector-storage/ffiwrapper/sealer_cgo.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/extern/sector-storage/ffiwrapper/sealer_cgo.go b/extern/sector-storage/ffiwrapper/sealer_cgo.go index d75501838..bae6cafb4 100644 --- a/extern/sector-storage/ffiwrapper/sealer_cgo.go +++ b/extern/sector-storage/ffiwrapper/sealer_cgo.go @@ -290,10 +290,6 @@ func (sb *Sealer) UnsealPiece(ctx context.Context, sector abi.SectorID, offset s defer opr.Close() // nolint padwriter := fr32.NewPadWriter(out) - if err != nil { - perr = xerrors.Errorf("creating new padded writer: %w", err) - return - } bsize := uint64(size.Padded()) 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())) - _, err = io.CopyN(bw, opr, int64(size)) + _, err := io.CopyN(bw, opr, int64(size)) if err != nil { perr = xerrors.Errorf("copying data: %w", err) return