Merge pull request #712 from filecoin-project/fix/clean-fpost-exit

storageminer: exit fpostScheduler loop cleanly
This commit is contained in:
Łukasz Magiera 2019-12-03 23:46:44 +01:00 committed by GitHub
commit 90dfb18ab8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,10 +49,17 @@ func (s *fpostScheduler) run(ctx context.Context) {
panic(err) panic(err)
} }
defer s.abortActivePoSt()
// not fine to panic after this point // not fine to panic after this point
for { for {
select { select {
case changes := <-notifs: case changes, ok := <-notifs:
if !ok {
log.Warn("fpostScheduler notifs channel closed")
return
}
ctx, span := trace.StartSpan(ctx, "fpostScheduler.headChange") ctx, span := trace.StartSpan(ctx, "fpostScheduler.headChange")
var lowest, highest *types.TipSet = s.cur, nil var lowest, highest *types.TipSet = s.cur, nil
@ -74,6 +81,8 @@ func (s *fpostScheduler) run(ctx context.Context) {
} }
span.End() span.End()
case <-ctx.Done():
return
} }
} }
} }