WangzJi commented on code in PR #3023:
URL: https://github.com/apache/dubbo-go/pull/3023#discussion_r2346308749


##########
filter/accesslog/filter.go:
##########
@@ -363,23 +400,32 @@ func (d *Data) toLogMessage() string {
 // Shutdown gracefully shuts down the access log filter
 // This should be called during application shutdown to prevent goroutine leaks
 func Shutdown() {
-       shutdownOnce.Do(func() {
-               if shutdownCancel != nil {
-                       shutdownCancel()
+       if accessLogFilter != nil {
+               accessLogFilter.shutdown()
+       }
+}
+
+// shutdown gracefully shuts down this filter instance
+func (f *Filter) shutdown() {
+       f.shutdownOnce.Do(func() {
+               // Cancel the context to signal goroutine to stop
+               if f.cancel != nil {
+                       f.cancel()
                }
-               if accessLogFilter != nil {
-                       if accessLogFilter.logChan != nil {
-                               close(accessLogFilter.logChan)
-                       }
-                       // Close all cached file handles
-                       accessLogFilter.fileLock.Lock()
-                       for path, file := range accessLogFilter.fileCache {
-                               if err := file.Close(); err != nil {
-                                       logger.Warnf("Error closing access log 
file %s: %v", path, err)
-                               }
-                               delete(accessLogFilter.fileCache, path)
+
+               // Close the channel to stop accepting new logs
+               if f.logChan != nil {
+                       close(f.logChan)
+               }
+
+               // Close all cached file handles
+               f.fileLock.Lock()
+               for path, file := range f.fileCache {
+                       if err := file.Close(); err != nil {
+                               logger.Warnf("Error closing access log file %s: 
%v", path, err)
                        }
-                       accessLogFilter.fileLock.Unlock()
+                       delete(f.fileCache, path)
                }
+               f.fileLock.Unlock()

Review Comment:
   Done in 
[96a574d](https://github.com/apache/dubbo-go/pull/3023/commits/96a574da30d0a002f2da7b66011d51e30538b414)



-- 
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

Reply via email to