From 9354720625ee2193e3ea22546e13756204365cdd Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 18 Apr 2017 19:42:27 +0000 Subject: Fix infinite streams in qps_test --- test/cpp/qps/client_sync.cc | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'test/cpp/qps/client_sync.cc') diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index a020adde51..da17f6bf7b 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -153,16 +153,22 @@ class SynchronousStreamingClient final : public SynchronousClient { StartThreads(num_threads_); } ~SynchronousStreamingClient() { + std::vector cleanup_threads; for (size_t i = 0; i < num_threads_; i++) { - auto stream = &stream_[i]; - if (*stream) { - (*stream)->WritesDone(); - Status s = (*stream)->Finish(); - if (!s.ok()) { - gpr_log(GPR_ERROR, "Stream %" PRIuPTR " received an error %s", i, - s.error_message().c_str()); + cleanup_threads.emplace_back([this, i]() { + auto stream = &stream_[i]; + if (*stream) { + (*stream)->WritesDone(); + Status s = (*stream)->Finish(); + if (!s.ok()) { + gpr_log(GPR_ERROR, "Stream %" PRIuPTR " received an error %s", i, + s.error_message().c_str()); + } } - } + }); + } + for (size_t i=0; i