fix deadlock
This commit is contained in:
parent
4003a37ffb
commit
0b38dd5310
@ -58,38 +58,33 @@ func (s *Spammer) Loop(quitChan <-chan bool) (<-chan bool, error) {
|
||||
sendDoneChan, sendErrChan := s.Sender.Send(senderQuit, txChan, watcher.PendingTxCh)
|
||||
|
||||
go func() {
|
||||
defer close(doneChan)
|
||||
for {
|
||||
select {
|
||||
case err := <-genErrChan:
|
||||
logrus.Errorf("tx generation error: %v", err)
|
||||
recoverClose(genQuit)
|
||||
<-genDoneChan
|
||||
recoverClose(senderQuit)
|
||||
<-sendDoneChan
|
||||
recoverClose(watcher.quitCh)
|
||||
case err := <-sendErrChan:
|
||||
logrus.Errorf("tx sending error: %v", err)
|
||||
recoverClose(genQuit)
|
||||
<-genDoneChan
|
||||
recoverClose(senderQuit)
|
||||
<-sendDoneChan
|
||||
recoverClose(watcher.quitCh)
|
||||
case <-quitChan:
|
||||
logrus.Info("shutting down tx spammer")
|
||||
recoverClose(genQuit)
|
||||
<-genDoneChan
|
||||
recoverClose(senderQuit)
|
||||
<-sendDoneChan
|
||||
recoverClose(watcher.quitCh)
|
||||
case <-sendDoneChan:
|
||||
recoverClose(watcher.quitCh)
|
||||
return
|
||||
case <-genDoneChan:
|
||||
recoverClose(senderQuit)
|
||||
}
|
||||
<-genDoneChan
|
||||
recoverClose(senderQuit)
|
||||
<-sendDoneChan
|
||||
recoverClose(watcher.quitCh)
|
||||
close(doneChan)
|
||||
}()
|
||||
|
||||
go func() {
|
||||
for err := range genErrChan {
|
||||
logrus.Errorf("tx generation error: %v", err)
|
||||
recoverClose(genQuit)
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
for err := range sendErrChan {
|
||||
logrus.Errorf("tx sending error: %v", err)
|
||||
recoverClose(genQuit)
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
<-quitChan
|
||||
logrus.Info("shutting down tx spammer")
|
||||
recoverClose(genQuit)
|
||||
}()
|
||||
|
||||
return doneChan, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user