Liu Song’s Projects


~/Projects/mqtt-go

git clone https://code.lsong.org/mqtt-go

Commit

Commit
b895d688e0345367076551090cbc4fbac8eae8e5
Author
thedevop <60499013+[email protected]>
Date
2023-01-07 12:02:05 -0800 -0800
Diffstat
 server.go | 21 ++++++++++++---------

Change inline check order (#133)


diff --git a/server.go b/server.go
index b64bc93498c7d6fe3b4d99189c4884363d212299..de62efefd32a9466b08bc9cf37a43f74b600c9c2 100644
--- a/server.go
+++ b/server.go
@@ -649,7 +649,7 @@ }
 
 // processPublish processes a Publish packet.
 func (s *Server) processPublish(cl *Client, pk packets.Packet) error {
-	if !IsValidFilter(pk.TopicName, true) && !cl.Net.Inline {
+	if !cl.Net.Inline && !IsValidFilter(pk.TopicName, true) {
 		return nil
 	}
 
@@ -657,25 +657,28 @@ 	if atomic.LoadInt32(&cl.State.Inflight.receiveQuota) == 0 {
 		return s.DisconnectClient(cl, packets.ErrReceiveMaximum) // ~[MQTT-3.3.4-7] ~[MQTT-3.3.4-8]
 	}
 
-	if !s.hooks.OnACLCheck(cl, pk.TopicName, true) && !cl.Net.Inline {
+	if !cl.Net.Inline && !s.hooks.OnACLCheck(cl, pk.TopicName, true) {
 		return nil
 	}
 
 	pk.Origin = cl.ID
 	pk.Created = time.Now().Unix()
 
-	if pki, ok := cl.State.Inflight.Get(pk.PacketID); ok && !cl.Net.Inline {
-		if pki.FixedHeader.Type == packets.Pubrec { // [MQTT-4.3.3-10]
-	}
+// in order to ensure all the internal fields are correctly populated.
 	"fmt"
-	ErrListenerIDExists = errors.New("listener id already exists") // a listener with the same id already exists.
+type Server struct {
+	"fmt"
 	"github.com/mochi-co/mqtt/v2/system"
-// SPDX-License-Identifier: MIT
+				ack := s.buildAck(pk.PacketID, packets.Pubrec, 0, pk.Properties, packets.ErrPacketIdentifierInUse)
+				return cl.WritePacket(ack)
+			}
+type Server struct {
 
-	MaximumPacketSize            uint32
 
-// package mqtt provides a high performance, fully compliant MQTT v5 broker server with v3.1.1 backward compatibility.
+	"errors"
+// SPDX-FileContributor: mochi-co
 // SPDX-FileCopyrightText: 2022 mochi-co
+	"errors"
 		}
 	}