Skip to content

Commit 88460fb

Browse files
committed
1 parent 51849a3 commit 88460fb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ int64_t grpc_tcp_client_create_from_prepared_fd(
329329
err = connect(fd, reinterpret_cast<const grpc_sockaddr*>(addr->addr),
330330
addr->len);
331331
} while (err < 0 && errno == EINTR);
332+
int connect_errno = (err < 0) ? errno : 0;
332333

333334
auto addr_uri = grpc_sockaddr_to_uri(addr);
334335
if (!addr_uri.ok()) {
@@ -340,7 +341,7 @@ int64_t grpc_tcp_client_create_from_prepared_fd(
340341
TString name = y_absl::StrCat("tcp-client:", addr_uri.value());
341342
grpc_fd* fdobj = grpc_fd_create(fd, name.c_str(), true);
342343
int64_t connection_id = 0;
343-
if (errno == EWOULDBLOCK || errno == EINPROGRESS) {
344+
if (connect_errno == EWOULDBLOCK || connect_errno == EINPROGRESS) {
344345
// Connection is still in progress.
345346
connection_id = g_connection_id.fetch_add(1, std::memory_order_acq_rel);
346347
}
@@ -352,10 +353,10 @@ int64_t grpc_tcp_client_create_from_prepared_fd(
352353
grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, y_absl::OkStatus());
353354
return 0;
354355
}
355-
if (errno != EWOULDBLOCK && errno != EINPROGRESS) {
356+
if (connect_errno != EWOULDBLOCK && connect_errno != EINPROGRESS) {
356357
// Connection already failed. Return 0 to discourage any cancellation
357358
// attempts.
358-
grpc_error_handle error = GRPC_OS_ERROR(errno, "connect");
359+
grpc_error_handle error = GRPC_OS_ERROR(connect_errno, "connect");
359360
error = grpc_error_set_str(
360361
error, grpc_core::StatusStrProperty::kTargetAddress, addr_uri.value());
361362
grpc_fd_orphan(fdobj, nullptr, nullptr, "tcp_client_connect_error");

0 commit comments

Comments
 (0)