mqtt: reduce use of goroutines in router to not start a new goroutine for each invocation of each callback

Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
Ron Evans
2020-04-07 01:19:58 +02:00
parent 6f213e97c3
commit 1987f424ad
+4 -8
View File
@@ -150,10 +150,8 @@ func (r *router) matchAndDispatch(messages <-chan *packets.PublishPacket, order
handlers = append(handlers, e.Value.(*route).callback)
} else {
hd := e.Value.(*route).callback
go func() {
hd(client, m)
//TODO: m.Ack()
}()
hd(client, m)
//TODO: m.Ack()
}
sent = true
}
@@ -162,10 +160,8 @@ func (r *router) matchAndDispatch(messages <-chan *packets.PublishPacket, order
if order {
handlers = append(handlers, r.defaultHandler)
} else {
go func() {
r.defaultHandler(client, m)
//TODO: m.Ack()
}()
r.defaultHandler(client, m)
//TODO: m.Ack()
}
}
for _, handler := range handlers {