From b8912c9fb11d06082724b9567a85573dd01b1a2b Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Mon, 7 Mar 2016 14:54:11 -0800 Subject: [PATCH] benchmark: change complete notifier first Fix https://github.com/coreos/etcd/issues/4708. --- tools/benchmark/cmd/watch.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/benchmark/cmd/watch.go b/tools/benchmark/cmd/watch.go index be32d4492..6bc83ec00 100644 --- a/tools/benchmark/cmd/watch.go +++ b/tools/benchmark/cmd/watch.go @@ -198,14 +198,16 @@ func doWatch(stream v3.Watcher, requests <-chan string) { func recvWatchChan(wch v3.WatchChan) { for range wch { + if atomic.LoadInt32(&nrRecvCompleted) == int32(eventsTotal) { + recvCompletedNotifier <- struct{}{} + break + } + st := time.Now() results <- result{duration: time.Since(st)} bar.Increment() atomic.AddInt32(&nrRecvCompleted, 1) - if atomic.LoadInt32(&nrRecvCompleted) == int32(eventsTotal) { - recvCompletedNotifier <- struct{}{} - } } }