aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps/client_sync.cc
diff options
context:
space:
mode:
authorGravatar Yuchen Zeng <zyc@google.com>2017-03-17 13:02:03 -0700
committerGravatar Yuchen Zeng <zyc@google.com>2017-03-17 16:00:17 -0700
commit9bc0d8200ec17ababe4c9cd6134a2cb7465365a6 (patch)
tree14ac57b2410205774b345de360b0886033d7d433 /test/cpp/qps/client_sync.cc
parentcabb1517e5ac3cdbe59415678d4f0d284f9fabda (diff)
parent40a947ef93aeddca3b606613f628d4d09f094e77 (diff)
Merge remote-tracking branch 'upstream/master' into cares_bazel_rule
Diffstat (limited to 'test/cpp/qps/client_sync.cc')
-rw-r--r--test/cpp/qps/client_sync.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc
index 498416c64a..a944c45496 100644
--- a/test/cpp/qps/client_sync.cc
+++ b/test/cpp/qps/client_sync.cc
@@ -129,7 +129,9 @@ class SynchronousUnaryClient final : public SynchronousClient {
grpc::ClientContext context;
grpc::Status s =
stub->UnaryCall(&context, request_, &responses_[thread_idx]);
- entry->set_value((UsageTimer::Now() - start) * 1e9);
+ if (s.ok()) {
+ entry->set_value((UsageTimer::Now() - start) * 1e9);
+ }
entry->set_status(s.error_code());
return true;
}
@@ -154,7 +156,7 @@ class SynchronousStreamingClient final : public SynchronousClient {
(*stream)->WritesDone();
Status s = (*stream)->Finish();
if (!s.ok()) {
- gpr_log(GPR_ERROR, "Stream %zu received an error %s", i,
+ gpr_log(GPR_ERROR, "Stream %" PRIuPTR " received an error %s", i,
s.error_message().c_str());
}
}
@@ -170,8 +172,17 @@ class SynchronousStreamingClient final : public SynchronousClient {
if (stream_[thread_idx]->Write(request_) &&
stream_[thread_idx]->Read(&responses_[thread_idx])) {
entry->set_value((UsageTimer::Now() - start) * 1e9);
+ // don't set the status since there isn't one yet
return true;
}
+ stream_[thread_idx]->WritesDone();
+ Status s = stream_[thread_idx]->Finish();
+ // don't set the value since the stream is failed and shouldn't be timed
+ entry->set_status(s.error_code());
+ if (!s.ok()) {
+ gpr_log(GPR_ERROR, "Stream %" PRIuPTR " received an error %s", thread_idx,
+ s.error_message().c_str());
+ }
auto* stub = channels_[thread_idx % channels_.size()].get_stub();
context_[thread_idx].~ClientContext();
new (&context_[thread_idx]) ClientContext();