mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-06 21:36:26 +00:00
p2p: stop mconn channel sends without timeout (#8906)
This commit is contained in:
@@ -100,7 +100,8 @@ type MConnection struct {
|
||||
|
||||
// used to ensure FlushStop and OnStop
|
||||
// are safe to call concurrently.
|
||||
stopMtx sync.Mutex
|
||||
stopMtx sync.Mutex
|
||||
stopSignal <-chan struct{}
|
||||
|
||||
cancel context.CancelFunc
|
||||
|
||||
@@ -207,6 +208,7 @@ func (c *MConnection) OnStart(ctx context.Context) error {
|
||||
c.quitSendRoutine = make(chan struct{})
|
||||
c.doneSendRoutine = make(chan struct{})
|
||||
c.quitRecvRoutine = make(chan struct{})
|
||||
c.stopSignal = ctx.Done()
|
||||
c.setRecvLastMsgAt(time.Now())
|
||||
go c.sendRoutine(ctx)
|
||||
go c.recvRoutine(ctx)
|
||||
@@ -681,6 +683,8 @@ func (ch *channel) sendBytes(bytes []byte) bool {
|
||||
return true
|
||||
case <-time.After(defaultSendTimeout):
|
||||
return false
|
||||
case <-ch.conn.stopSignal:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user