lizining1231 commented on code in PR #3713:
URL: https://github.com/apache/dubbo-go/pull/3713#discussion_r3894813128
##########
filter/accesslog/filter.go:
##########
@@ -90,19 +90,28 @@ type Filter struct {
ctx context.Context
cancel context.CancelFunc
shutdownOnce sync.Once
+ started chan struct{} // closed once processLogs is running
+ done chan struct{} // closed once processLogs has exited
Review Comment:
因为主要是测试引发的race,channel给测试用。
原测试靠 runtime.NumGoroutine() 全局计数 + sleep 来判断 goroutine 启动/退出,但 Shutdown()
是异步的,上一轮测试的 goroutine 还在退出中,恰好与本轮新启动的 goroutine 一增一减抵消,两次采样计数不变,断言就会失败。
这两个 channel 是给测试用的标志,close(started) / close(done) 由 goroutine
自己发出,测试等信号而不是计数,close 的 happens-before 保证收到信号时 goroutine
一定已启动/已退出,不会出现采样计数不变导致的偶发断言失败
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]