From f66abe5fcb2dc65c67d37b404346f64d3d2fb8ee Mon Sep 17 00:00:00 2001 From: TrickIt Date: Mon, 31 May 2021 15:26:26 +0800 Subject: [PATCH] fix: if packet is disconnect from client, then need to break the read packet loop before next loop start, and clear will msg. (#120) --- broker/client.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/broker/client.go b/broker/client.go index 7cc703d..955254e 100644 --- a/broker/client.go +++ b/broker/client.go @@ -180,6 +180,12 @@ func (c *client) readLoop() { return } + // if packet is disconnect from client, then need to break the read packet loop and clear will msg. + if _, isDisconnect := packet.(*packets.DisconnectPacket); isDisconnect { + c.info.willMsg = nil + c.cancelFunc() + } + msg := &Message{ client: c, packet: packet,