Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mock sealer: grab lock in ReadPiece #9207

Merged
merged 1 commit into from
Aug 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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