You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "peien luo (JIRA)" <ji...@apache.org> on 2015/08/09 06:40:46 UTC
[jira] [Commented] (THRIFT-2958) connect() interrupted is not
handled properly in TSocket
[ https://issues.apache.org/jira/browse/THRIFT-2958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14663260#comment-14663260 ]
peien luo commented on THRIFT-2958:
-----------------------------------
I remember I saw this case happen when the thrift server was running in gdb and there are lots of requests to the server, not very easy to reproduce.
> 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
>
> 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
(v6.3.4#6332)