Skip to content

Commit 1987f42

Browse files
committed
mqtt: reduce use of goroutines in router to not start a new goroutine for each invocation of each callback
Signed-off-by: Ron Evans <[email protected]>
1 parent 6f213e9 commit 1987f42

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

net/mqtt/router.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,8 @@ func (r *router) matchAndDispatch(messages <-chan *packets.PublishPacket, order
150150
handlers = append(handlers, e.Value.(*route).callback)
151151
} else {
152152
hd := e.Value.(*route).callback
153-
go func() {
154-
hd(client, m)
155-
//TODO: m.Ack()
156-
}()
153+
hd(client, m)
154+
//TODO: m.Ack()
157155
}
158156
sent = true
159157
}
@@ -162,10 +160,8 @@ func (r *router) matchAndDispatch(messages <-chan *packets.PublishPacket, order
162160
if order {
163161
handlers = append(handlers, r.defaultHandler)
164162
} else {
165-
go func() {
166-
r.defaultHandler(client, m)
167-
//TODO: m.Ack()
168-
}()
163+
r.defaultHandler(client, m)
164+
//TODO: m.Ack()
169165
}
170166
}
171167
for _, handler := range handlers {

0 commit comments

Comments
 (0)