users@grizzly.java.net

non-blocking connect etc

From: Sebastian Dehne <sebastian_at_dehnes.com>
Date: Fri, 03 Oct 2008 00:15:05 +0200

Hi list,

I'm new to Girzzy and I'm trying to figure out how it works. I have two
questions. I'm using the release 1.8.6

A) I see that TCPConnectorHandler.connect() blocks until the connection
is completed. Is there a way to do non-blocking outbound connect? I mean
I don't want to exhaust my thread-pool in case I have many outgoing
connections which don't complete within shortly.


B) Thread-safety. Image you have two threads, threadA and threadB.
threadA calls into TCPConnectorHandler.connect() and sets a new instance
to the field isConnectedLatch at line 280 before calling
selectorHandler.connect() on line 282. After that, threadB, which
handles the onConnect() event, might call into this class via
finishConnect() and try to access isConnectedLatch before threadA had a
chance to complete line 283. Since isConnectedLatch is neither guarded
by a lock nor volatile there is a risk of threadB not seeing the new
value of isConnectedLatch (visibility) which threadA just wrote. Or am I
misunderstanding something?


Thanks for the help

Sebastian