From b3d1f2a4f8763ea5567ded2b37bdb16d259e64dd Mon Sep 17 00:00:00 2001 From: Hannah Shi Date: Fri, 17 Jul 2020 22:34:35 +0000 Subject: [PATCH] avoid destroy channel more than once --- src/php/ext/grpc/channel.c | 2 +- src/php/ext/grpc/php_grpc.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c index 47483812b25..e9b6d67f817 100644 --- a/src/php/ext/grpc/channel.c +++ b/src/php/ext/grpc/channel.c @@ -50,7 +50,7 @@ extern HashTable grpc_persistent_list; extern HashTable grpc_target_upper_bound_map; void free_grpc_channel_wrapper(grpc_channel_wrapper* channel, bool free_channel) { - if (free_channel) { + if (free_channel && channel->wrapped) { grpc_channel_destroy(channel->wrapped); channel->wrapped = NULL; } diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c index f567d8c59c3..01764a71202 100644 --- a/src/php/ext/grpc/php_grpc.c +++ b/src/php/ext/grpc/php_grpc.c @@ -159,6 +159,7 @@ void destroy_grpc_channels() { wrapped_channel.wrapper = le->channel; grpc_channel_wrapper *channel = wrapped_channel.wrapper; grpc_channel_destroy(channel->wrapped); + channel->wrapped = NULL; PHP_GRPC_HASH_FOREACH_END() }