diff options
author | David Garcia Quintas <dgq@google.com> | 2016-11-30 10:50:39 -0800 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2016-11-30 10:50:39 -0800 |
commit | 523a4aa0a06de21ffe23582b373d18488f78c8e2 (patch) | |
tree | 2a84233b3ff1e4c50c9d83e85c5dbc33cb30600c /test/cpp/qps | |
parent | a0a3c411d18e71931aaff43d750d9407372f2878 (diff) |
PR comments
Diffstat (limited to 'test/cpp/qps')
-rw-r--r-- | test/cpp/qps/json_run_localhost.cc | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/test/cpp/qps/json_run_localhost.cc b/test/cpp/qps/json_run_localhost.cc index b6e96601d1..409abed12e 100644 --- a/test/cpp/qps/json_run_localhost.cc +++ b/test/cpp/qps/json_run_localhost.cc @@ -46,10 +46,11 @@ #include "test/cpp/util/subprocess.h" using grpc::SubProcess; -typedef std::unique_ptr<SubProcess> SubProcessPtr; -SubProcessPtr g_driver; + constexpr auto kNumWorkers = 2; -std::vector<SubProcessPtr> g_workers(2); + +static SubProcess* g_driver; +static SubProcess* g_workers[kNumWorkers]; template <class T> std::string as_string(const T& val) { @@ -61,8 +62,9 @@ std::string as_string(const T& val) { static void sighandler(int sig) { const int errno_saved = errno; g_driver->Interrupt(); - for (const auto& worker : g_workers) - if (worker) worker->Interrupt(); + for (int i = 0; i < kNumWorkers; ++i) { + if (g_workers[i]) g_workers[i]->Interrupt(); + } errno = errno_saved; } @@ -100,7 +102,7 @@ int main(int argc, char** argv) { const auto port = grpc_pick_unused_port_or_die(); std::vector<std::string> args = {bin_dir + "/qps_worker", "-driver_port", as_string(port)}; - g_workers[i].reset(new SubProcess(args)); + g_workers[i] = new SubProcess(args); if (!first) env << ","; env << "localhost:" << port; first = false; @@ -112,20 +114,25 @@ int main(int argc, char** argv) { args.push_back(argv[i]); } - g_driver.reset(new SubProcess(args)); + g_driver = new SubProcess(args); const int driver_join_status = g_driver->Join(); if (driver_join_status != 0) { LogStatus(driver_join_status, "driver"); } - for (const auto& worker : g_workers) { - if (worker) worker->Interrupt(); + for (int i = 0; i < kNumWorkers; ++i) { + if (g_workers[i]) g_workers[i]->Interrupt(); } - for (const auto& worker : g_workers) { - if (worker) { - const int worker_status = worker->Join(); + + for (int i = 0; i < kNumWorkers; ++i) { + if (g_workers[i]) { + const int worker_status = g_workers[i]->Join(); if (worker_status != 0) { LogStatus(worker_status, "worker"); } } } + + delete g_driver; + for (int i = 0; i < kNumWorkers; ++i) delete g_workers[i]; + GPR_ASSERT(driver_join_status == 0); } |