You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Bryan Duxbury (JIRA)" <ji...@apache.org> on 2010/08/10 03:17:18 UTC

[jira] Assigned: (THRIFT-843) TNonblockingSocket connects without a timeout

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

Bryan Duxbury reassigned THRIFT-843:
------------------------------------

    Assignee: Bryan Duxbury

> TNonblockingSocket connects without a timeout
> ---------------------------------------------
>
>                 Key: THRIFT-843
>                 URL: https://issues.apache.org/jira/browse/THRIFT-843
>             Project: Thrift
>          Issue Type: Bug
>            Reporter: Eric Jensen
>            Assignee: Bryan Duxbury
>             Fix For: 0.4
>
>
> Unlike TSocket which takes a timeout in its constructor and uses it as both the connect timeout and the so timeout, TNonblockingSocket only supports a setTimeout method which sets the so timeout but doesn't apply the timeout to the connect operation.  Instead, it calls the convenience method SocketChannel.open in its constructor, which calls a blocking, connection-free connect before we set the socket into non-blocking mode or set an so timeout on it.  
> A solution would be to do something like the following:
> SocketChannel socketChannel = SocketChannel.open();
> this.socket_ = socketChannel.socket();
> socket_.setSoTimeout(timeout_);
> socket_.connect(new InetSocketAddress(host, port), timeout_);
> socketChannel.configureBlocking(false);
> That's a bit weird since in TSocket we do the blocking connect in the open() method instead of the constructor, but it seems like a better fix than to refactor all the non-blocking stuff to also call open().
> Also, the initSocket() method in TNonblockingSocket is invalid entirely (although unreachable) as it would overwrite the Socket from the channel with a new, unconnected blocking one.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.