Skip to content

Commit

Permalink
fix: if packet is disconnect from client, then need to break the read…
Browse files Browse the repository at this point in the history
… packet loop before next loop start, and clear will msg. (fhmq#120)
  • Loading branch information
TrickIt authored May 31, 2021
1 parent ccbe364 commit f66abe5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions broker/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f66abe5

Please sign in to comment.