Add a null check for the endpoint on shutdown

pull/15781/head
kpayson64 7 years ago committed by Mehrdad Afshari
parent 17ae5cef8d
commit 8cbd880b1f
  1. 5
      src/core/lib/channel/handshaker.cc

@ -223,6 +223,10 @@ static bool call_next_handshaker_locked(grpc_handshake_manager* mgr,
mgr->index == mgr->count) { mgr->index == mgr->count) {
if (error == GRPC_ERROR_NONE && mgr->shutdown) { if (error == GRPC_ERROR_NONE && mgr->shutdown) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("handshaker shutdown"); error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("handshaker shutdown");
// 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 // TODO(roth): It is currently necessary to shutdown endpoints
// before destroying then, even when we know that there are no // before destroying then, even when we know that there are no
// pending read/write callbacks. This should be fixed, at which // pending read/write callbacks. This should be fixed, at which
@ -236,6 +240,7 @@ static bool call_next_handshaker_locked(grpc_handshake_manager* mgr,
gpr_free(mgr->args.read_buffer); gpr_free(mgr->args.read_buffer);
mgr->args.read_buffer = nullptr; mgr->args.read_buffer = nullptr;
} }
}
if (grpc_handshaker_trace.enabled()) { if (grpc_handshaker_trace.enabled()) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"handshake_manager %p: handshaking complete -- scheduling " "handshake_manager %p: handshaking complete -- scheduling "

Loading…
Cancel
Save