From 9dc5c15b563eae017a782a547d015d328fd015fe Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 3 Jun 2015 11:34:53 -0700 Subject: [PATCH] Account for time difference in mac and linux --- include/grpc++/config.h | 2 +- include/grpc++/time.h | 2 +- src/cpp/util/time.cc | 2 +- test/cpp/qps/client.h | 6 ++++-- test/cpp/qps/client_async.cc | 5 ++++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/grpc++/config.h b/include/grpc++/config.h index 55b2a644822..8d674efef85 100644 --- a/include/grpc++/config.h +++ b/include/grpc++/config.h @@ -46,7 +46,7 @@ #define GRPC_CXX0X_NO_OVERRIDE 1 #define GRPC_CXX0X_NO_CHRONO 1 #define GRPC_CXX0X_NO_THREAD 1 -#endif +#endif #endif // Visual Studio #ifndef __clang__ diff --git a/include/grpc++/time.h b/include/grpc++/time.h index 25c446429c7..da22bca47ac 100644 --- a/include/grpc++/time.h +++ b/include/grpc++/time.h @@ -85,7 +85,7 @@ namespace grpc { // from and to should be absolute time. void Timepoint2Timespec(const std::chrono::system_clock::time_point& from, gpr_timespec* to); -void Timepoint2Timespec(const std::chrono::high_resolution_clock::time_point& from, +void TimepointHR2Timespec(const std::chrono::high_resolution_clock::time_point& from, gpr_timespec* to); std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t); diff --git a/src/cpp/util/time.cc b/src/cpp/util/time.cc index 83292e93385..beb58ef3f79 100644 --- a/src/cpp/util/time.cc +++ b/src/cpp/util/time.cc @@ -60,7 +60,7 @@ void Timepoint2Timespec(const system_clock::time_point& from, to->tv_nsec = nsecs.count(); } -void Timepoint2Timespec(const high_resolution_clock::time_point& from, +void TimepointHR2Timespec(const high_resolution_clock::time_point& from, gpr_timespec* to) { high_resolution_clock::duration deadline = from.time_since_epoch(); seconds secs = duration_cast(deadline); diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index f028fc7c0f7..7d75ed7d742 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -44,17 +44,19 @@ namespace grpc { -// Specialize Timepoint for high res clock as we need that +#if defined(__APPLE__) +// Specialize Timepoint for high res clock as we need that template <> class TimePoint { public: TimePoint(const std::chrono::high_resolution_clock::time_point& time) { - Timepoint2Timespec(time, &time_); + TimepointHR2Timespec(time, &time_); } gpr_timespec raw_time() const { return time_; } private: gpr_timespec time_; }; +#endif namespace testing { diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index e91a7a191c1..e4ce93adb4b 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -204,7 +204,7 @@ class AsyncClient : public Client { short_deadline = issue_allowed_[thread_idx] ? next_issue_[thread_idx] : deadline; } - + bool got_event; switch (cli_cqs_[thread_idx]->AsyncNext(&got_tag, &ok, short_deadline)) { @@ -215,6 +215,9 @@ class AsyncClient : public Client { case CompletionQueue::GOT_EVENT: got_event = true; break; + default: + GPR_ASSERT(false); + break; } if (grpc_time_source::now() > deadline) { // we have missed some 1-second deadline, which is too much gpr_log(GPR_INFO, "Missed an RPC deadline, giving up");