Always remove subroute when queuing message on the connection. (#18550)

This commit is contained in:
Klaus Post 2023-11-28 11:22:29 -08:00 committed by GitHub
parent bea0b050cd
commit 0bb81f2e9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -544,7 +544,10 @@ func (c *Connection) send(msg []byte) error {
// queueMsg queues a message, with an optional payload.
// sender should not reference msg.Payload
func (c *Connection) queueMsg(msg message, payload sender) error {
msg.Flags |= c.baseFlags
// Add baseflags.
msg.Flags.Set(c.baseFlags)
// This cannot encode subroute.
msg.Flags.Clear(FlagSubroute)
if payload != nil {
if cap(msg.Payload) < payload.Msgsize() {
old := msg.Payload

View file

@ -186,6 +186,16 @@ func (f Flags) String() string {
return "[" + strings.Join(res, ",") + "]"
}
// Set one or more flags on f.
func (f *Flags) Set(flags Flags) {
*f |= flags
}
// Clear one or more flags on f.
func (f *Flags) Clear(flags Flags) {
*f &^= flags
}
// parse an incoming message.
func (m *message) parse(b []byte) (*subHandlerID, []byte, error) {
var sub *subHandlerID