mirror of
https://github.com/mochi-mqtt/server.git
synced 2025-09-27 04:26:23 +08:00
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:
@@ -362,12 +362,10 @@ func (s *Server) attachClient(cl *Client, listener string) error {
|
|||||||
s.hooks.OnDisconnect(cl, err, expire)
|
s.hooks.OnDisconnect(cl, err, expire)
|
||||||
close(cl.State.outbound)
|
close(cl.State.outbound)
|
||||||
|
|
||||||
if expire {
|
if expire && atomic.LoadUint32(&cl.State.isTakenOver) == 0 {
|
||||||
cl.ClearInflights(math.MaxInt64, 0)
|
cl.ClearInflights(math.MaxInt64, 0)
|
||||||
s.UnsubscribeClient(cl)
|
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
|
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]
|
if pk.Connect.Clean || (existing.Properties.Clean && existing.Properties.ProtocolVersion < 5) { // [MQTT-3.1.2-4] [MQTT-3.1.4-4]
|
||||||
s.UnsubscribeClient(existing)
|
s.UnsubscribeClient(existing)
|
||||||
existing.ClearInflights(math.MaxInt64, 0)
|
existing.ClearInflights(math.MaxInt64, 0)
|
||||||
|
atomic.StoreUint32(&existing.State.isTakenOver, 1)
|
||||||
return false // [MQTT-3.2.2-3]
|
return false // [MQTT-3.2.2-3]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user