Skip expire cleanup for isTakenOver session (#183)

* Skip expire cleanup for isTakenOver session

* Set prev connection to isTakenOver on CleanSession

#173.
This commit is contained in:
thedevop
2023-02-28 12:53:26 -08:00
committed by GitHub
parent 46babc89c8
commit da79faa972

View File

@@ -362,12 +362,10 @@ func (s *Server) attachClient(cl *Client, listener string) error {
s.hooks.OnDisconnect(cl, err, expire)
close(cl.State.outbound)
if expire {
if expire && atomic.LoadUint32(&cl.State.isTakenOver) == 0 {
cl.ClearInflights(math.MaxInt64, 0)
s.UnsubscribeClient(cl)
if atomic.LoadUint32(&cl.State.isTakenOver) == 0 {
s.Clients.Delete(cl.ID) // [MQTT-4.1.0-2] ![MQTT-3.1.2-23]
}
s.Clients.Delete(cl.ID) // [MQTT-4.1.0-2] ![MQTT-3.1.2-23] }
}
return err
@@ -444,6 +442,7 @@ func (s *Server) inheritClientSession(pk packets.Packet, cl *Client) bool {
if pk.Connect.Clean || (existing.Properties.Clean && existing.Properties.ProtocolVersion < 5) { // [MQTT-3.1.2-4] [MQTT-3.1.4-4]
s.UnsubscribeClient(existing)
existing.ClearInflights(math.MaxInt64, 0)
atomic.StoreUint32(&existing.State.isTakenOver, 1)
return false // [MQTT-3.2.2-3]
}