Protect close of nil outbound channel

This commit is contained in:
mochi-co
2023-04-21 22:00:27 +01:00
parent ed7fd836e1
commit 17fb7dadbc

View File

@@ -364,7 +364,9 @@ func (cl *Client) Stop(err error) {
cl.State.stopCause.Store(err)
}
close(cl.State.outbound)
if cl.State.outbound != nil {
close(cl.State.outbound)
}
atomic.StoreUint32(&cl.State.done, 1)
atomic.StoreInt64(&cl.State.disconnected, time.Now().Unix())