LQyt2012 commented on code in PR #3023: URL: https://github.com/apache/dubbo-go/pull/3023#discussion_r2347335641
########## registry/nacos/service_discovery.go: ########## @@ -86,6 +86,23 @@ func (n *nacosServiceDiscovery) Destroy() error { logger.Errorf("Unregister nacos instance:%+v, err:%+v", inst, err) } } + + // Clean up listeners to prevent potential leaks + n.listenerLock.Lock() + // Unsubscribe from all services to stop callbacks + for serviceName := range n.instanceListenerMap { + err := n.namingClient.Client().Unsubscribe(&vo.SubscribeParam{ + ServiceName: serviceName, + GroupName: n.group, + }) + if err != nil { + logger.Warnf("Failed to unsubscribe from service %s: %v", serviceName, err) + } + } + // Clear the listener map + n.instanceListenerMap = make(map[string]*gxset.HashSet) + n.listenerLock.Unlock() Review Comment: Use defer to unlock to make sure the lock always be released. ########## filter/accesslog/filter.go: ########## @@ -182,6 +189,63 @@ func (f *Filter) OnResponse(_ context.Context, result result.Result, _ base.Invo return result } +// processLogs runs in a background goroutine to process log data +func (f *Filter) processLogs() { + defer func() { + if r := recover(); r != nil { + logger.Errorf("AccessLog processLogs panic: %v", r) + } + f.drainLogs() + }() + + for { + select { + case accessLogData, ok := <-f.logChan: + if !ok { + return + } + f.writeLogToFileWithTimeout(accessLogData, 5*time.Second) Review Comment: Could you make the timeout parameter configurable or a member of the filter struct if a system always takes more than 5 seconds to write logs to the file, there will be no logs written to the file. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For additional commands, e-mail: notifications-h...@dubbo.apache.org