@@ -329,6 +329,7 @@ int64_t grpc_tcp_client_create_from_prepared_fd(
329
329
err = connect (fd, reinterpret_cast <const grpc_sockaddr*>(addr->addr ),
330
330
addr->len );
331
331
} while (err < 0 && errno == EINTR);
332
+ int connect_errno = (err < 0 ) ? errno : 0 ;
332
333
333
334
auto addr_uri = grpc_sockaddr_to_uri (addr);
334
335
if (!addr_uri.ok ()) {
@@ -340,7 +341,7 @@ int64_t grpc_tcp_client_create_from_prepared_fd(
340
341
TString name = y_absl::StrCat (" tcp-client:" , addr_uri.value ());
341
342
grpc_fd* fdobj = grpc_fd_create (fd, name.c_str (), true );
342
343
int64_t connection_id = 0 ;
343
- if (errno == EWOULDBLOCK || errno == EINPROGRESS) {
344
+ if (connect_errno == EWOULDBLOCK || connect_errno == EINPROGRESS) {
344
345
// Connection is still in progress.
345
346
connection_id = g_connection_id.fetch_add (1 , std::memory_order_acq_rel);
346
347
}
@@ -352,10 +353,10 @@ int64_t grpc_tcp_client_create_from_prepared_fd(
352
353
grpc_core::ExecCtx::Run (DEBUG_LOCATION, closure, y_absl::OkStatus ());
353
354
return 0 ;
354
355
}
355
- if (errno != EWOULDBLOCK && errno != EINPROGRESS) {
356
+ if (connect_errno != EWOULDBLOCK && connect_errno != EINPROGRESS) {
356
357
// Connection already failed. Return 0 to discourage any cancellation
357
358
// attempts.
358
- grpc_error_handle error = GRPC_OS_ERROR (errno , " connect" );
359
+ grpc_error_handle error = GRPC_OS_ERROR (connect_errno , " connect" );
359
360
error = grpc_error_set_str (
360
361
error, grpc_core::StatusStrProperty::kTargetAddress , addr_uri.value ());
361
362
grpc_fd_orphan (fdobj, nullptr , nullptr , " tcp_client_connect_error" );
0 commit comments