You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Trustin Lee (JIRA)" <ji...@apache.org> on 2006/05/09 05:26:21 UTC

[jira] Updated: (DIRMINA-212) Possible connection leak in SocketConnector ?

     [ http://issues.apache.org/jira/browse/DIRMINA-212?page=all ]

Trustin Lee updated DIRMINA-212:
--------------------------------

    Fix Version: 0.8.3
                 0.9.5
        Version: 0.8.2
      Assign To: Trustin Lee

> Possible connection leak in SocketConnector ?
> ---------------------------------------------
>
>          Key: DIRMINA-212
>          URL: http://issues.apache.org/jira/browse/DIRMINA-212
>      Project: Directory MINA
>         Type: Bug

>     Versions: 0.8.2, 0.9.4
>  Environment: Observed on Solaris 9
> Java HotSpot Server VM 1.4.2_11
>     Reporter: Dominique Prunier
>     Assignee: Trustin Lee
>      Fix For: 0.9.5, 0.8.3

>
> 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