Skip to content

Commit b895d68

Browse files
authored
Change inline check order (#133)
1 parent a600cd4 commit b895d68

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

server.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -649,28 +649,30 @@ func (s *Server) InjectPacket(cl *Client, pk packets.Packet) error {
649649

650650
// processPublish processes a Publish packet.
651651
func (s *Server) processPublish(cl *Client, pk packets.Packet) error {
652-
if !IsValidFilter(pk.TopicName, true) && !cl.Net.Inline {
652+
if !cl.Net.Inline && !IsValidFilter(pk.TopicName, true) {
653653
return nil
654654
}
655655

656656
if atomic.LoadInt32(&cl.State.Inflight.receiveQuota) == 0 {
657657
return s.DisconnectClient(cl, packets.ErrReceiveMaximum) // ~[MQTT-3.3.4-7] ~[MQTT-3.3.4-8]
658658
}
659659

660-
if !s.hooks.OnACLCheck(cl, pk.TopicName, true) && !cl.Net.Inline {
660+
if !cl.Net.Inline && !s.hooks.OnACLCheck(cl, pk.TopicName, true) {
661661
return nil
662662
}
663663

664664
pk.Origin = cl.ID
665665
pk.Created = time.Now().Unix()
666666

667-
if pki, ok := cl.State.Inflight.Get(pk.PacketID); ok && !cl.Net.Inline {
668-
if pki.FixedHeader.Type == packets.Pubrec { // [MQTT-4.3.3-10]
669-
ack := s.buildAck(pk.PacketID, packets.Pubrec, 0, pk.Properties, packets.ErrPacketIdentifierInUse)
670-
return cl.WritePacket(ack)
671-
}
672-
if ok := cl.State.Inflight.Delete(pk.PacketID); ok { // [MQTT-4.3.2-5]
673-
atomic.AddInt64(&s.Info.Inflight, -1)
667+
if !cl.Net.Inline {
668+
if pki, ok := cl.State.Inflight.Get(pk.PacketID); ok {
669+
if pki.FixedHeader.Type == packets.Pubrec { // [MQTT-4.3.3-10]
670+
ack := s.buildAck(pk.PacketID, packets.Pubrec, 0, pk.Properties, packets.ErrPacketIdentifierInUse)
671+
return cl.WritePacket(ack)
672+
}
673+
if ok := cl.State.Inflight.Delete(pk.PacketID); ok { // [MQTT-4.3.2-5]
674+
atomic.AddInt64(&s.Info.Inflight, -1)
675+
}
674676
}
675677
}
676678

0 commit comments

Comments
 (0)