[
https://issues.apache.org/jira/browse/THRIFT-2958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18112775#comment-18112775
]
Sylwester Lachiewicz edited comment on THRIFT-2958 at 9/8/26 1:44 PM:
----------------------------------------------------------------------
Still live in {{openConnection()}}: {{THRIFT_EINTR}} is neither
{{THRIFT_EINPROGRESS}} nor {{THRIFT_EWOULDBLOCK}}, so an interrupted
{{connect()}} falls through to the throw at
[TSocket.cpp:366|https://github.com/apache/thrift/blob/master/lib/cpp/src/thrift/transport/TSocket.cpp#L366]
— the behaviour described here. The {{THRIFT_POLL}} that follows is not
retried on EINTR either (line 402). The EINTR retry that does exist is in
{{TSocket::read()}}, a different path. Reopening.
was (Author: slachiewicz):
connect() interruption is handled:
[lib/cpp/src/thrift/transport/TSocket.cpp|https://github.com/apache/thrift/blob/master/lib/cpp/src/thrift/transport/TSocket.cpp]
retries on {{THRIFT_EINTR}} (line 567, bounded by {{maxRecvRetries_}}),
alongside the read paths (lines 201, 230). Resolving as Fixed.
> connect() interrupted is not handled properly in TSocket
> --------------------------------------------------------
>
> Key: THRIFT-2958
> URL: https://issues.apache.org/jira/browse/THRIFT-2958
> Project: Thrift
> Issue Type: Bug
> Components: C++ - Library
> Affects Versions: 0.9.1, 0.9.2
> Reporter: peien luo
> Priority: Major
>
> In ./lib/cpp/src/thrift/transport/TSocket.cpp, function void
> TSocket::openConnection(struct addrinfo *res)
> If *nix connect() is interrupted, it should not be aborted and throw a
> TException, this will result subsequent connect() failures.
> When we close the socket connection on signal EINTR and retry, we will end up
> in same old state and stuck in loop.
> Instead, if connect() is interrupted by a signal that is caught, while
> blocked waiting to establish a connection, connect() shall fail and set
> connect() to [EINTR], but the connection request shall not be aborted, and
> the connection shall be established asynchronously.
> In the current thrift code, when connect() fails due to interruptions, an
> exception is thrown and user have no way to establish the connection later.
> 273 ret = connect(socket_, res->ai_addr,
> static_cast<int>(res->ai_addrlen));
> 274 }
> 275
> 276 // success case
> 277 if (ret == 0) {
> 278 goto done;
> 279 }
> 280
> 281 if ((THRIFT_GET_SOCKET_ERROR != THRIFT_EINPROGRESS) &&
> (THRIFT_GET_SOCKET_ERROR != THRIFT_EWOULDBLOCK)) {
> 282 int errno_copy = THRIFT_GET_SOCKET_ERROR;
> 283 GlobalOutput.perror("TSocket::open() connect() " + getSocketInfo(),
> errno_copy);
> 284 throw TTransportException(TTransportException::NOT_OPEN, "connect()
> failed", errno_copy);
> 285 }
--
This message was sent by Atlassian Jira
(v8.20.10#820010)