Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blocksync: wait for poolRoutine to stop in (*Reactor).OnStop (tenderm…
…int#1879) * blocksync: wait for poolRoutine to stop in (*Reactor).OnStop blocksync.(*Reactor).poolRoutine goroutine lifetime was not supervised, so OnStop returning did not provide a guarantee that it was done. As a result, the other services could be stopped and a subsequent call to bcR.blockExec.ApplyBlock would cause a panic, typically a leveldb closed error. This change uses a sync.WaitGroup to ensure that OnStop returns after poolRoutine has returned. This also triggers the poolRoutine method to return on a signal from bcR.pool.Quit() instead of just bcR.Quit(), which seems to be important as (*Reactor).OnStop itself can only stop the BlockPool (bcR.pool), while the BaseReactor.BaseService's quit channel will only be closed _after_ (*Reactor).OnStop has returned. * rename wg field, comment on strayish select before retry * break poolRoutine on either Quit before quick retry * update changelog * break the loop with an IsRunning check * do the waitgroup Add and Defer at the same site for clarity * check both services IsRunning in poolRoutine * fix oopsie --------- Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
- Loading branch information