Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-2958

connect() interrupted is not handled properly in TSocket

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.9.1, 0.9.2
    • None
    • C++ - Library
    • None

    Description

      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 }

      Attachments

        Activity

          People

            Unassigned Unassigned
            nullptr peien luo
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: