Skip to content
Snippets Groups Projects
Commit 7366fe6d authored by Craig Tiller's avatar Craig Tiller Committed by GitHub
Browse files

Merge pull request #10709 from ctiller/infinite_stream

Fix infinite streams in qps_test
parents d7b72ee9 f26caeed
Branches
Tags
No related merge requests found
...@@ -153,16 +153,22 @@ class SynchronousStreamingClient final : public SynchronousClient { ...@@ -153,16 +153,22 @@ 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++) {
auto stream = &stream_[i]; cleanup_threads.emplace_back([this, i]() {
if (*stream) { auto stream = &stream_[i];
(*stream)->WritesDone(); if (*stream) {
Status s = (*stream)->Finish(); (*stream)->WritesDone();
if (!s.ok()) { Status s = (*stream)->Finish();
gpr_log(GPR_ERROR, "Stream %" PRIuPTR " received an error %s", i, if (!s.ok()) {
s.error_message().c_str()); gpr_log(GPR_ERROR, "Stream %" PRIuPTR " received an error %s", i,
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 { ...@@ -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
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment