mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
peer: make PingManager.Stop infallible
This commit is contained in:
parent
94a9baefeb
commit
61191a576d
@ -1257,15 +1257,13 @@ func (p *Brontide) Disconnect(reason error) {
|
||||
|
||||
p.log.Infof(err.Error())
|
||||
|
||||
// Stop PingManager before closing TCP connection.
|
||||
p.pingManager.Stop()
|
||||
|
||||
// Ensure that the TCP connection is properly closed before continuing.
|
||||
p.cfg.Conn.Close()
|
||||
|
||||
close(p.quit)
|
||||
|
||||
if err := p.pingManager.Stop(); err != nil {
|
||||
p.log.Errorf("couldn't stop pingManager during disconnect: %v",
|
||||
err)
|
||||
}
|
||||
}
|
||||
|
||||
// String returns the string representation of this peer.
|
||||
|
@ -196,12 +196,10 @@ func (m *PingManager) pingHandler() {
|
||||
}
|
||||
}
|
||||
|
||||
// Stop interrupts the goroutines that the PingManager owns. Can only be called
|
||||
// when the PingManager is running.
|
||||
func (m *PingManager) Stop() error {
|
||||
// Stop interrupts the goroutines that the PingManager owns.
|
||||
func (m *PingManager) Stop() {
|
||||
if m.pingTicker == nil {
|
||||
return errors.New("PingManager cannot be stopped because it " +
|
||||
"isn't running")
|
||||
return
|
||||
}
|
||||
|
||||
m.stopped.Do(func() {
|
||||
@ -211,8 +209,6 @@ func (m *PingManager) Stop() error {
|
||||
m.pingTicker.Stop()
|
||||
m.pingTimeout.Stop()
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// setPingState is a private method to keep track of all of the fields we need
|
||||
|
@ -83,6 +83,6 @@ func TestPingManager(t *testing.T) {
|
||||
require.False(t, test.result)
|
||||
}
|
||||
|
||||
require.NoError(t, mgr.Stop(), "Could not stop pingManager")
|
||||
mgr.Stop()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user