This is an automated email from the ASF dual-hosted git repository.

rxl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git


The following commit(s) were added to refs/heads/master by this push:
     new e6d73af  Fix perf-produce cannot be closed (#255)
e6d73af is described below

commit e6d73af17c3c38f25c2121f18a34f028d4f8a9f3
Author: 冉小龙 <[email protected]>
AuthorDate: Tue May 19 15:35:43 2020 +0800

    Fix perf-produce cannot be closed (#255)
    
    * Fix perf-produce cannot be closed
    
    Signed-off-by: xiaolong.ran <[email protected]>
    
    * fix comments
    
    Signed-off-by: xiaolong.ran <[email protected]>
    
    * fix comments
    
    Signed-off-by: xiaolong.ran <[email protected]>
    
    * fix comments
    
    Signed-off-by: xiaolong.ran <[email protected]>
---
 perf/perf-producer.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/perf/perf-producer.go b/perf/perf-producer.go
index 5660a80..a3e6cde 100644
--- a/perf/perf-producer.go
+++ b/perf/perf-producer.go
@@ -98,7 +98,7 @@ func produce(produceArgs *ProduceArgs, stop <-chan struct{}) {
 
        ch := make(chan float64)
 
-       go func() {
+       go func(stopCh <-chan struct{}) {
                var rateLimiter *rate.RateLimiter
                if produceArgs.Rate > 0 {
                        rateLimiter = rate.New(produceArgs.Rate, time.Second)
@@ -106,7 +106,7 @@ func produce(produceArgs *ProduceArgs, stop <-chan 
struct{}) {
 
                for {
                        select {
-                       case <-stop:
+                       case <-stopCh:
                                return
                        default:
                        }
@@ -128,7 +128,7 @@ func produce(produceArgs *ProduceArgs, stop <-chan 
struct{}) {
                                ch <- latency
                        })
                }
-       }()
+       }(stop)
 
        // Print stats of the publish rate and latencies
        tick := time.NewTicker(10 * time.Second)

Reply via email to