remove go routines for handling reciept of subscribed messages

This commit is contained in:
Matthew R. Kasun
2022-02-08 13:13:43 -05:00
parent 05ada0402a
commit 3b7f4e31b1

View File

@@ -224,8 +224,6 @@ var All mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) {
// NodeUpdate -- mqtt message handler for /update/<NodeID> topic // NodeUpdate -- mqtt message handler for /update/<NodeID> topic
func NodeUpdate(client mqtt.Client, msg mqtt.Message) { func NodeUpdate(client mqtt.Client, msg mqtt.Message) {
//potentiall blocking i/o so do this in a go routine
go func() {
var newNode models.Node var newNode models.Node
var cfg config.ClientConfig var cfg config.ClientConfig
var network = parseNetworkFromTopic(msg.Topic()) var network = parseNetworkFromTopic(msg.Topic())
@@ -333,12 +331,10 @@ func NodeUpdate(client mqtt.Client, msg mqtt.Message) {
ncutils.Log("error applying dns" + err.Error()) ncutils.Log("error applying dns" + err.Error())
} }
} }
}()
} }
// UpdatePeers -- mqtt message handler for peers/<Network>/<NodeID> topic // UpdatePeers -- mqtt message handler for peers/<Network>/<NodeID> topic
func UpdatePeers(client mqtt.Client, msg mqtt.Message) { func UpdatePeers(client mqtt.Client, msg mqtt.Message) {
go func() {
var peerUpdate models.PeerUpdate var peerUpdate models.PeerUpdate
var network = parseNetworkFromTopic(msg.Topic()) var network = parseNetworkFromTopic(msg.Topic())
var cfg = config.ClientConfig{} var cfg = config.ClientConfig{}
@@ -374,7 +370,6 @@ func UpdatePeers(client mqtt.Client, msg mqtt.Message) {
return return
} }
ncutils.Log(fmt.Sprintf("received peer update on network, %s", cfg.Network)) ncutils.Log(fmt.Sprintf("received peer update on network, %s", cfg.Network))
}()
} }
// MonitorKeepalive - checks time last server keepalive received. If more than 3+ minutes, notify and resubscribe // MonitorKeepalive - checks time last server keepalive received. If more than 3+ minutes, notify and resubscribe
@@ -456,7 +451,6 @@ func Resubscribe(client mqtt.Client, cfg *config.ClientConfig) error {
// UpdateKeys -- updates private key and returns new publickey // UpdateKeys -- updates private key and returns new publickey
func UpdateKeys(cfg *config.ClientConfig, client mqtt.Client) error { func UpdateKeys(cfg *config.ClientConfig, client mqtt.Client) error {
ncutils.Log("received message to update keys") ncutils.Log("received message to update keys")
//potentiall blocking i/o so do this in a go routine
key, err := wgtypes.GeneratePrivateKey() key, err := wgtypes.GeneratePrivateKey()
if err != nil { if err != nil {
ncutils.Log("error generating privatekey " + err.Error()) ncutils.Log("error generating privatekey " + err.Error())