Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
fix leak on pubsub subscription
Antonio Ojea5c355c563382
diff --git a/cmd/sam-node/node.go b/cmd/sam-node/node.goindex f940e982..5aaf35e9 100644--- a/cmd/sam-node/node.go+++ b/cmd/sam-node/node.go@@ -783,13 +783,18 @@ func (n *SamNode) verifyEvent(event *api.MeshEvent) bool {func (n *SamNode) subscribeToTopic(ctx context.Context, topicName string) error {n.mu.Lock()- topic, ok := n.topics[topicName]+ _, ok := n.topics[topicName]var err error+ var topic *pubsub.Topicif !ok {topic, err = n.PubSub.Join(topicName)if err == nil {n.topics[topicName] = topic}+ } else {+ // Already joined and subscribed.+ n.mu.Unlock()+ return nil}n.mu.Unlock()if err != nil {