Merge pull request #10709 from ctiller/infinite_stream

Fix infinite streams in qps_test
pull/10732/head
Craig Tiller 8 years ago committed by GitHub
commit 7366fe6df3
  1. 8
      test/cpp/qps/client_sync.cc

@ -153,7 +153,9 @@ class SynchronousStreamingClient final : public SynchronousClient {
StartThreads(num_threads_); StartThreads(num_threads_);
} }
~SynchronousStreamingClient() { ~SynchronousStreamingClient() {
std::vector<std::thread> cleanup_threads;
for (size_t i = 0; i < num_threads_; i++) { for (size_t i = 0; i < num_threads_; i++) {
cleanup_threads.emplace_back([this, i]() {
auto stream = &stream_[i]; auto stream = &stream_[i];
if (*stream) { if (*stream) {
(*stream)->WritesDone(); (*stream)->WritesDone();
@ -163,6 +165,10 @@ class SynchronousStreamingClient final : public SynchronousClient {
s.error_message().c_str()); s.error_message().c_str());
} }
} }
});
}
for (size_t i = 0; i < num_threads_; i++) {
cleanup_threads[i].join();
} }
} }
@ -179,6 +185,8 @@ class SynchronousStreamingClient final : public SynchronousClient {
if ((messages_per_stream_ != 0) && if ((messages_per_stream_ != 0) &&
(++messages_issued_[thread_idx] < messages_per_stream_)) { (++messages_issued_[thread_idx] < messages_per_stream_)) {
return true; return true;
} else if (messages_per_stream_ == 0) {
return true;
} else { } else {
// Fall through to the below resetting code after finish // Fall through to the below resetting code after finish
} }

Loading…
Cancel
Save