Skip to content

Commit

Permalink
Merge pull request #9207 from filecoin-project/asr/deflake
Browse files Browse the repository at this point in the history
fix: mock sealer: grab lock in ReadPiece
  • Loading branch information
magik6k authored Aug 24, 2022
2 parents 4a6ea4c + 5e80276 commit f1f31d1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions storage/sealer/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit f1f31d1

Please sign in to comment.