peien luo created THRIFT-2958: --------------------------------- Summary: 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 Affects Versions: 0.9.2, 0.9.1 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)