You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "James E. King, III (JIRA)" <ji...@apache.org> on 2015/05/04 15:39:07 UTC

[jira] [Reopened] (THRIFT-3069) C++ TServerSocket leaks socket on fcntl get or set flags error

     [ https://issues.apache.org/jira/browse/THRIFT-3069?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James E. King, III reopened THRIFT-3069:
----------------------------------------
      Assignee: James E. King, III

> C++ TServerSocket leaks socket on fcntl get or set flags error
> --------------------------------------------------------------
>
>                 Key: THRIFT-3069
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3069
>             Project: Thrift
>          Issue Type: Bug
>          Components: C++ - Library
>    Affects Versions: 0.9.2
>            Reporter: James E. King, III
>            Assignee: James E. King, III
>            Priority: Minor
>             Fix For: 0.9.3
>
>
> Walking through the C++ TServerSocket code, there are opportunities for the newly accepted client socket to leak:
> {noformat}  THRIFT_SOCKET clientSocket = ::accept(serverSocket_,
>                               (struct sockaddr *) &clientAddress,
>                               (socklen_t *) &size);
>   if (clientSocket == -1) {
>     int errno_copy = THRIFT_GET_SOCKET_ERROR;
>     GlobalOutput.perror("TServerSocket::acceptImpl() ::accept() ", errno_copy);
>     throw TTransportException(TTransportException::UNKNOWN, "accept()", errno_copy);
>   }
>   // Make sure client socket is blocking
>   int flags = THRIFT_FCNTL(clientSocket, THRIFT_F_GETFL, 0);
>   if (flags == -1) {
>     int errno_copy = THRIFT_GET_SOCKET_ERROR;
>     GlobalOutput.perror("TServerSocket::acceptImpl() THRIFT_FCNTL() THRIFT_F_GETFL ", errno_copy);
>     throw TTransportException(TTransportException::UNKNOWN, "THRIFT_FCNTL(THRIFT_F_GETFL)", errno_copy);
>   }
>   if (-1 == THRIFT_FCNTL(clientSocket, THRIFT_F_SETFL, flags & ~THRIFT_O_NONBLOCK)) {
>     int errno_copy = THRIFT_GET_SOCKET_ERROR;
>     GlobalOutput.perror("TServerSocket::acceptImpl() THRIFT_FCNTL() THRIFT_F_SETFL ~THRIFT_O_NONBLOCK ", errno_copy);
>     throw TTransportException(TTransportException::UNKNOWN, "THRIFT_FCNTL(THRIFT_F_SETFL)", errno_copy);
>   }
> {noformat}
> Specifically in both of the latter error handling cases, {{clientSocket}} is not cleaned up.  Given this is highly unlikely to occur, I set the priority of this issue to Minor.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)