diff options
author | Sree Kuchibhotla <sreek@google.com> | 2017-06-22 15:08:55 -0700 |
---|---|---|
committer | Sree Kuchibhotla <sreek@google.com> | 2017-06-22 15:08:55 -0700 |
commit | bfce58742d349d5d7b12c026e60dc93652f45c74 (patch) | |
tree | 7aa6bd782b683a304324c5fa6fe64f8ad41f9ff6 /test | |
parent | c8d249ccd2241abbd97cbb0a10c2449f69e571ae (diff) |
Refcount grpc_alarm object so that grpc_alarm_destroy can safely be called before the alarm event is dequeued from the completion queue
Diffstat (limited to 'test')
-rw-r--r-- | test/core/surface/alarm_test.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/core/surface/alarm_test.c b/test/core/surface/alarm_test.c index baaa05928e..6971d92074 100644 --- a/test/core/surface/alarm_test.c +++ b/test/core/surface/alarm_test.c @@ -73,6 +73,21 @@ static void test_alarm(void) { GPR_ASSERT(ev.success == 0); grpc_alarm_destroy(alarm); } + { + /* alarm_destroy before cq_next */ + grpc_event ev; + void *tag = create_test_tag(); + grpc_alarm *alarm = + grpc_alarm_create(cc, grpc_timeout_seconds_to_deadline(2), tag); + + grpc_alarm_destroy(alarm); + ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(1), + NULL); + GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); + GPR_ASSERT(ev.tag == tag); + GPR_ASSERT(ev.success == 0); + } + shutdown_and_destroy(cc); } |