You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2015/04/03 03:06:52 UTC

[jira] [Commented] (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:comment-tabpanel&focusedCommentId=14393858#comment-14393858 ] 

ASF GitHub Bot commented on THRIFT-3069:
----------------------------------------

GitHub user jeking3 opened a pull request:

    https://github.com/apache/thrift/pull/419

    [THRIFT-3069] fix socket leak if fcntl fails

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jeking3/thrift bugfix/THRIFT-3069-leak-socket-fcntl-fails

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/419.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #419
    
----
commit 467f67d13248c433fc3a9b50882e39837dc62376
Author: Jim King <ji...@simplivity.com>
Date:   2015-04-03T01:01:00Z

    [THRIFT-3069] fix socket leak if fcntl fails

----


> 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
>            Priority: Minor
>
> 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)