aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2015-05-22 13:50:20 -0700
committerGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2015-05-22 13:50:20 -0700
commit5fa2eab4f4071303b269155c0393e2b63483af7b (patch)
tree34bf76d616713252dc177a6cbabc71b0db2bf39f /test
parent7a875f1a744dc3bb2f1a52a0e13e192d92d3dfc5 (diff)
parent8ebcec484fccefc1538854f8f0d1beadd5c0e720 (diff)
Merge pull request #1706 from ctiller/streaming-crash-boom-bang
Fix shutdown crash in async streaming test
Diffstat (limited to 'test')
-rw-r--r--test/cpp/qps/server_async.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index 58499f345f..b9998405f6 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -99,12 +99,15 @@ class AsyncQpsServerTest : public Server {
while (srv_cq_->Next(&got_tag, &ok)) {
ServerRpcContext *ctx = detag(got_tag);
// The tag is a pointer to an RPC context to invoke
- if (ctx->RunNextState(ok) == false) {
+ bool still_going = ctx->RunNextState(ok);
+ std::lock_guard<std::mutex> g(shutdown_mutex_);
+ if (!shutdown_) {
// this RPC context is done, so refresh it
- std::lock_guard<std::mutex> g(shutdown_mutex_);
- if (!shutdown_) {
+ if (!still_going) {
ctx->Reset();
}
+ } else {
+ return;
}
}
return;
@@ -116,11 +119,15 @@ class AsyncQpsServerTest : public Server {
{
std::lock_guard<std::mutex> g(shutdown_mutex_);
shutdown_ = true;
- srv_cq_->Shutdown();
}
for (auto thr = threads_.begin(); thr != threads_.end(); thr++) {
thr->join();
}
+ srv_cq_->Shutdown();
+ bool ok;
+ void *got_tag;
+ while (srv_cq_->Next(&got_tag, &ok))
+ ;
while (!contexts_.empty()) {
delete contexts_.front();
contexts_.pop_front();