From: Sergey Matveev Date: Sat, 27 Apr 2019 18:32:48 +0000 (+0300) Subject: Stop goroutine when state is dead X-Git-Tag: 4.0^2~8 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=eaa9dd1fb0e9373efa70682eeb9cf39669267ccb;p=nncp.git Stop goroutine when state is dead --- diff --git a/src/cypherpunks.ru/nncp/sp.go b/src/cypherpunks.ru/nncp/sp.go index fdfb14a..e309b98 100644 --- a/src/cypherpunks.ru/nncp/sp.go +++ b/src/cypherpunks.ru/nncp/sp.go @@ -546,6 +546,9 @@ func (state *SPState) StartWorkers( if state.xxOnly == "" || state.xxOnly == TTx { go func() { for range time.Tick(time.Second) { + if state.NotAlive() { + return + } for _, payload := range state.ctx.infosOur( state.Node.Id, state.nice,