Possible connection leak in SocketConnector ?
---------------------------------------------
Key: DIRMINA-212
URL: http://issues.apache.org/jira/browse/DIRMINA-212
Project: Directory MINA
Type: Bug
Versions: 0.9.4
Environment: Observed on Solaris 9
Java HotSpot Server VM 1.4.2_11
Reporter: Dominique Prunier
In SocketConnector class, it seems that there may be a race condition where
mina lose reference on a channel that has not been closed. Since Sun removed
any finalize methods in channels, it will remains connected forever.
This has been observed with server which doens't accept more than one
connection. First connection timesout according to mina but channel is not
closed in processTimedOutSessions method. Key is removed from selector thus it
is not notified (then handlers never see the sessionOpened event) when
connection finally gets up late (observed with tcpdump). The reference on this
connection is lost and socket is never closed (observed with lsof). Then
subsequent connection always fail since we already have a phantom one opened.
private void processTimedOutSessions( Set keys )
{
long currentTime = System.currentTimeMillis();
Iterator it = keys.iterator();
while( it.hasNext() )
{
SelectionKey key = ( SelectionKey ) it.next();
if( !key.isValid() )
continue;
ConnectionRequest entry = ( ConnectionRequest ) key.attachment();
if( currentTime >= entry.deadline )
{
entry.setException( new ConnectException() );
key.cancel(); <-------------- MISSING CLOSE HERE ???
}
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira