service: change stop interface (#7816)

This commit is contained in:
Sam Kleinman
2022-02-17 11:23:32 -05:00
committed by GitHub
parent 38e29590ff
commit 28d34d635c
30 changed files with 129 additions and 226 deletions
+2 -6
View File
@@ -235,9 +235,7 @@ func (pool *BlockPool) PopRequest() {
defer pool.mtx.Unlock()
if r := pool.requesters[pool.height]; r != nil {
if err := r.Stop(); err != nil {
pool.logger.Error("error stopping requester", "err", err)
}
r.Stop()
delete(pool.requesters, pool.height)
pool.height++
pool.lastAdvance = time.Now()
@@ -676,9 +674,7 @@ OUTER_LOOP:
case <-ctx.Done():
return
case <-bpr.pool.exitedCh:
if err := bpr.Stop(); err != nil {
bpr.logger.Error("error stopped requester", "err", err)
}
bpr.Stop()
return
case peerID := <-bpr.redoCh:
if peerID == bpr.peerID {
+2 -6
View File
@@ -187,9 +187,7 @@ func (r *Reactor) OnStart(ctx context.Context) error {
// blocking until they all exit.
func (r *Reactor) OnStop() {
if r.blockSync.IsSet() {
if err := r.pool.Stop(); err != nil {
r.logger.Error("failed to stop pool", "err", err)
}
r.pool.Stop()
}
// wait for the poolRoutine and requestRoutine goroutines to gracefully exit
@@ -485,9 +483,7 @@ FOR_LOOP:
continue
}
if err := r.pool.Stop(); err != nil {
r.logger.Error("failed to stop pool", "err", err)
}
r.pool.Stop()
r.blockSync.UnSet()