From 5e8027663141b9ccb6c5ccff101a82db53da366f Mon Sep 17 00:00:00 2001 From: Aayush <arajasek94@gmail.com> Date: Tue, 23 Aug 2022 17:24:28 -0400 Subject: [PATCH] fix: mock sealer: grab lock in ReadPiece --- storage/sealer/mock/mock.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/storage/sealer/mock/mock.go b/storage/sealer/mock/mock.go index baa644cc187..5b0afd35c81 100644 --- a/storage/sealer/mock/mock.go +++ b/storage/sealer/mock/mock.go @@ -439,6 +439,9 @@ func (mgr *SectorMgr) GenerateWindowPoStWithVanilla(ctx context.Context, proofTy func (mgr *SectorMgr) ReadPiece(ctx context.Context, sector storiface.SectorRef, offset storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize, ticket abi.SealRandomness, unsealed cid.Cid) (mount.Reader, bool, error) { off := storiface.UnpaddedByteIndex(0) var piece cid.Cid + + mgr.lk.Lock() + for _, c := range mgr.sectors[sector.ID].pieces { piece = c if off >= offset { @@ -451,6 +454,8 @@ func (mgr *SectorMgr) ReadPiece(ctx context.Context, sector storiface.SectorRef, } br := bytes.NewReader(mgr.pieces[piece][:size]) + mgr.lk.Unlock() + return struct { io.ReadCloser io.Seeker