diff options
author | Sree Kuchibhotla <sreek@google.com> | 2017-07-14 11:25:14 -0700 |
---|---|---|
committer | Sree Kuchibhotla <sreek@google.com> | 2017-07-14 11:29:28 -0700 |
commit | a69878a2172e1514e9411a1e0d275f7870b80b6b (patch) | |
tree | da62eca4d5dd75c1a09d033a77ce7e9cd1c8bd55 /test | |
parent | bd4439c4a63e5d3aa0bacc5d724ede28de7903e7 (diff) |
fix memory leaks due to not calling grpc_shutdown in bm_cq_multiple_threads
Diffstat (limited to 'test')
-rw-r--r-- | test/cpp/microbenchmarks/bm_cq_multiple_threads.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc index 1e3830a556..f79db15a47 100644 --- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc +++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc @@ -41,6 +41,7 @@ namespace testing { static void* g_tag = (void*)(intptr_t)10; // Some random number static grpc_completion_queue* g_cq; static grpc_event_engine_vtable g_vtable; +static const grpc_event_engine_vtable* g_old_vtable; static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* ps, grpc_closure* closure) { @@ -72,7 +73,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps, grpc_pollset_worker** worker, gpr_timespec now, gpr_timespec deadline) { if (gpr_time_cmp(deadline, gpr_time_0(GPR_CLOCK_MONOTONIC)) == 0) { - gpr_log(GPR_ERROR, "no-op"); + gpr_log(GPR_DEBUG, "no-op"); return GRPC_ERROR_NONE; } @@ -98,7 +99,12 @@ static void init_engine_vtable() { static void setup() { grpc_init(); + + /* Override the event engine with our test event engine (g_vtable); but before + * that, save the current event engine in g_old_vtable. We will have to set + * g_old_vtable back before calling grpc_shutdown() */ init_engine_vtable(); + g_old_vtable = grpc_get_event_engine_test_only(); grpc_set_event_engine_test_only(&g_vtable); g_cq = grpc_completion_queue_create_for_next(NULL); @@ -115,6 +121,10 @@ static void teardown() { } grpc_completion_queue_destroy(g_cq); + + /* Restore the old event engine before calling grpc_shutdown */ + grpc_set_event_engine_test_only(g_old_vtable); + grpc_shutdown(); } /* A few notes about Multi-threaded benchmarks: |