This is an automated email from the ASF dual-hosted git repository.
dinglei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-go.git
The following commit(s) were added to refs/heads/master by this push:
new 7ae788d fix Panic when close traceDispatcher (#1027)
7ae788d is described below
commit 7ae788dead078adf3223db712b14fb6bdb7837bb
Author: wenxuwan <[email protected]>
AuthorDate: Thu Apr 6 11:21:00 2023 +0800
fix Panic when close traceDispatcher (#1027)
* seperate interface and implement
* fix panic when close tracedispatcher
* Restore rlog/log.go
* Delete default.go
---
internal/trace.go | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/internal/trace.go b/internal/trace.go
index ad30281..f7cea8d 100644
--- a/internal/trace.go
+++ b/internal/trace.go
@@ -305,8 +305,11 @@ func (td *traceDispatcher) GetTraceTopicName() string {
func (td *traceDispatcher) Start() {
td.running = true
td.cli.Start()
+ maxWaitDuration := 5 * time.Millisecond
+ td.ticker = time.NewTicker(maxWaitDuration)
+ maxWaitTime := maxWaitDuration.Nanoseconds()
go primitive.WithRecover(func() {
- td.process()
+ td.process(maxWaitTime)
})
}
@@ -334,12 +337,9 @@ func (td *traceDispatcher) Append(ctx TraceContext) bool {
}
// process
-func (td *traceDispatcher) process() {
+func (td *traceDispatcher) process(maxWaitTime int64) {
var count int
var batch []TraceContext
- maxWaitDuration := 5 * time.Millisecond
- maxWaitTime := maxWaitDuration.Nanoseconds()
- td.ticker = time.NewTicker(maxWaitDuration)
lastput := time.Now()
for {
select {