Skip to content

Commit

Permalink
Merge pull request #3374 from IPFSMain-Official/fix-packing-sector
Browse files Browse the repository at this point in the history
ignore resend SectorStartPacking event. and fix StartPacking's unsealedInfoMap lock
  • Loading branch information
magik6k committed Aug 28, 2020
2 parents 932ab61 + 93dc336 commit a7ef612
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions extern/storage-sealing/sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,23 @@ func (m *Sealing) Remove(ctx context.Context, sid abi.SectorNumber) error {

// Caller should NOT hold m.unsealedInfoMap.lk
func (m *Sealing) StartPacking(sectorID abi.SectorNumber) error {
// locking here ensures that when the SectorStartPacking event is sent, the sector won't be picked up anywhere else
m.unsealedInfoMap.lk.Lock()
defer m.unsealedInfoMap.lk.Unlock()

// cannot send SectorStartPacking to sectors that have already been packed, otherwise it will cause the state machine to exit
if _, ok := m.unsealedInfoMap.infos[sectorID]; !ok {
log.Warnf("call start packing, but sector %v not in unsealedInfoMap.infos, maybe have called", sectorID)
return nil
}
log.Infof("Starting packing sector %d", sectorID)
err := m.sectors.Send(uint64(sectorID), SectorStartPacking{})
if err != nil {
return err
}
log.Infof("send Starting packing event success sector %d", sectorID)

m.unsealedInfoMap.lk.Lock()
delete(m.unsealedInfoMap.infos, sectorID)
m.unsealedInfoMap.lk.Unlock()

return nil
}
Expand Down

0 comments on commit a7ef612

Please sign in to comment.