From 65fdff36832e2fb5454ecbfe7341ba3a267ad8ab Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 5 May 2020 02:04:10 -0700 Subject: [PATCH] Include the destination address in synchronous TCP connect errors --- src/core/lib/iomgr/tcp_client_posix.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/tcp_client_posix.cc b/src/core/lib/iomgr/tcp_client_posix.cc index 928c70d8a98..4abf33bc223 100644 --- a/src/core/lib/iomgr/tcp_client_posix.cc +++ b/src/core/lib/iomgr/tcp_client_posix.cc @@ -302,9 +302,13 @@ void grpc_tcp_client_create_from_prepared_fd( return; } if (errno != EWOULDBLOCK && errno != EINPROGRESS) { + grpc_error* error = GRPC_OS_ERROR(errno, "connect"); + char* addr_str = grpc_sockaddr_to_uri(addr); + error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS, + grpc_slice_from_copied_string(addr_str)); + gpr_free(addr_str); grpc_fd_orphan(fdobj, nullptr, nullptr, "tcp_client_connect_error"); - grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, - GRPC_OS_ERROR(errno, "connect")); + grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, error); return; }