diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2018-02-01 00:37:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-01 00:37:59 +0100 |
commit | e294279e398566fb6f41256c79b9d3e886a0d156 (patch) | |
tree | 03fcd162e2f3bde279ac0b926056fd4e5e7553d5 /test/cpp/performance | |
parent | d6358a5b0a473042927dbd0e9e0102eac5a89159 (diff) | |
parent | 889bb7fde4c3f8f36c3821e16b0b66870e68526d (diff) |
Merge pull request #14236 from jtattermusch/fix_passthru_endpoint_race
Make grpc_passthru_endpoint_stats refcounted
Diffstat (limited to 'test/cpp/performance')
-rw-r--r-- | test/cpp/performance/writes_per_rpc_test.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc index 0b9dc83f2b..b7d951a86e 100644 --- a/test/cpp/performance/writes_per_rpc_test.cc +++ b/test/cpp/performance/writes_per_rpc_test.cc @@ -142,18 +142,24 @@ class EndpointPairFixture { class InProcessCHTTP2 : public EndpointPairFixture { public: - InProcessCHTTP2(Service* service) - : EndpointPairFixture(service, MakeEndpoints()) {} + InProcessCHTTP2(Service* service, grpc_passthru_endpoint_stats* stats) + : EndpointPairFixture(service, MakeEndpoints(stats)), stats_(stats) {} - int writes_performed() const { return stats_.num_writes; } + virtual ~InProcessCHTTP2() { + if (stats_ != nullptr) { + grpc_passthru_endpoint_stats_destroy(stats_); + } + } + + int writes_performed() const { return stats_->num_writes; } private: - grpc_passthru_endpoint_stats stats_; + grpc_passthru_endpoint_stats* stats_; - grpc_endpoint_pair MakeEndpoints() { + static grpc_endpoint_pair MakeEndpoints(grpc_passthru_endpoint_stats* stats) { grpc_endpoint_pair p; grpc_passthru_endpoint_create(&p.client, &p.server, initialize_stuff.rq(), - &stats_); + stats); return p; } }; @@ -162,7 +168,8 @@ static double UnaryPingPong(int request_size, int response_size) { const int kIterations = 10000; EchoTestService::AsyncService service; - std::unique_ptr<InProcessCHTTP2> fixture(new InProcessCHTTP2(&service)); + std::unique_ptr<InProcessCHTTP2> fixture( + new InProcessCHTTP2(&service, grpc_passthru_endpoint_stats_create())); EchoRequest send_request; EchoResponse send_response; EchoResponse recv_response; |