diff options
author | 2018-06-13 17:06:57 -0700 | |
---|---|---|
committer | 2018-06-13 17:06:57 -0700 | |
commit | 26287ea74d5d23be77e8206ca5188511d1fe60f6 (patch) | |
tree | 2fa7cfbc35ef3c18aa4085b6018840f56b2683e1 /src/core | |
parent | 3f9308ce1f8cb42c96901c1700f0b9dbb531f186 (diff) | |
parent | 0293cebe1bf21d1baa6ad25714e7c1ee29eb5b6b (diff) |
Merge pull request #15727 from kpayson64/null_endpoint
Add a null check for the endpoint on shutdown
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lib/channel/handshaker.cc | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/core/lib/channel/handshaker.cc b/src/core/lib/channel/handshaker.cc index 86f8699e04..ad3250b7e9 100644 --- a/src/core/lib/channel/handshaker.cc +++ b/src/core/lib/channel/handshaker.cc @@ -223,18 +223,23 @@ static bool call_next_handshaker_locked(grpc_handshake_manager* mgr, mgr->index == mgr->count) { if (error == GRPC_ERROR_NONE && mgr->shutdown) { error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("handshaker shutdown"); - // TODO(roth): It is currently necessary to shutdown endpoints - // before destroying then, even when we know that there are no - // pending read/write callbacks. This should be fixed, at which - // point this can be removed. - grpc_endpoint_shutdown(mgr->args.endpoint, GRPC_ERROR_REF(error)); - grpc_endpoint_destroy(mgr->args.endpoint); - mgr->args.endpoint = nullptr; - grpc_channel_args_destroy(mgr->args.args); - mgr->args.args = nullptr; - grpc_slice_buffer_destroy_internal(mgr->args.read_buffer); - gpr_free(mgr->args.read_buffer); - mgr->args.read_buffer = nullptr; + // It is possible that the endpoint has already been destroyed by + // a shutdown call while this callback was sitting on the ExecCtx + // with no error. + if (mgr->args.endpoint != nullptr) { + // TODO(roth): It is currently necessary to shutdown endpoints + // before destroying then, even when we know that there are no + // pending read/write callbacks. This should be fixed, at which + // point this can be removed. + grpc_endpoint_shutdown(mgr->args.endpoint, GRPC_ERROR_REF(error)); + grpc_endpoint_destroy(mgr->args.endpoint); + mgr->args.endpoint = nullptr; + grpc_channel_args_destroy(mgr->args.args); + mgr->args.args = nullptr; + grpc_slice_buffer_destroy_internal(mgr->args.read_buffer); + gpr_free(mgr->args.read_buffer); + mgr->args.read_buffer = nullptr; + } } if (grpc_handshaker_trace.enabled()) { gpr_log(GPR_INFO, |