Merge pull request #9207 from filecoin-project/asr/deflake

fix: mock sealer: grab lock in ReadPiece
This commit is contained in:
Łukasz Magiera 2022-08-23 21:55:18 -04:00 committed by GitHub
commit f1f31d1067
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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