From 0bb81f2e9cf7b6d9151c1cb0976b697ccb9e1d6c Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Tue, 28 Nov 2023 11:22:29 -0800 Subject: [PATCH] Always remove subroute when queuing message on the connection. (#18550) --- internal/grid/connection.go | 5 ++++- internal/grid/msg.go | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/grid/connection.go b/internal/grid/connection.go index f6617e0c7..6c2f7ddc6 100644 --- a/internal/grid/connection.go +++ b/internal/grid/connection.go @@ -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 diff --git a/internal/grid/msg.go b/internal/grid/msg.go index 86e20fb06..f55230f40 100644 --- a/internal/grid/msg.go +++ b/internal/grid/msg.go @@ -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