summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaxim-yurchuk <[email protected]>2024-08-15 01:04:48 +0300
committermaxim-yurchuk <[email protected]>2024-08-15 01:15:25 +0300
commit5fcd49974a967d31fef1fea125d97975454595bf (patch)
tree4a95e026e0ae52203a73e0088bfaf7da2b94e41e
parent8fbad371206713c1a4e15a89dc2b43d99e0e64c9 (diff)
Backport grpc fix (late errno read)
https://github.com/grpc/grpc/commit/abbaa20223c95255f36a1bc70b3505e9daa006a2 -- коммит который бэкпортится, доп инфа в тикете 66e2b3bb0cc6c90cb9387ff0e5766abd2780b5c7
-rw-r--r--contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.cc b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.cc
index 720cf269f2c..4e437e034cb 100644
--- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.cc
+++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.cc
@@ -329,6 +329,7 @@ int64_t grpc_tcp_client_create_from_prepared_fd(
err = connect(fd, reinterpret_cast<const grpc_sockaddr*>(addr->addr),
addr->len);
} while (err < 0 && errno == EINTR);
+ int connect_errno = (err < 0) ? errno : 0;
auto addr_uri = grpc_sockaddr_to_uri(addr);
if (!addr_uri.ok()) {
@@ -340,7 +341,7 @@ int64_t grpc_tcp_client_create_from_prepared_fd(
TString name = y_absl::StrCat("tcp-client:", addr_uri.value());
grpc_fd* fdobj = grpc_fd_create(fd, name.c_str(), true);
int64_t connection_id = 0;
- if (errno == EWOULDBLOCK || errno == EINPROGRESS) {
+ if (connect_errno == EWOULDBLOCK || connect_errno == EINPROGRESS) {
// Connection is still in progress.
connection_id = g_connection_id.fetch_add(1, std::memory_order_acq_rel);
}
@@ -352,10 +353,10 @@ int64_t grpc_tcp_client_create_from_prepared_fd(
grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, y_absl::OkStatus());
return 0;
}
- if (errno != EWOULDBLOCK && errno != EINPROGRESS) {
+ if (connect_errno != EWOULDBLOCK && connect_errno != EINPROGRESS) {
// Connection already failed. Return 0 to discourage any cancellation
// attempts.
- grpc_error_handle error = GRPC_OS_ERROR(errno, "connect");
+ grpc_error_handle error = GRPC_OS_ERROR(connect_errno, "connect");
error = grpc_error_set_str(
error, grpc_core::StatusStrProperty::kTargetAddress, addr_uri.value());
grpc_fd_orphan(fdobj, nullptr, nullptr, "tcp_client_connect_error");