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


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.

Reply via email to