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

Dominique Prunier commented on DIRMINA-212:
-------------------------------------------

I'm testing revision 405785 (with the fix).

I already tested with sucess the following code (which is almost the same).

            if( currentTime >= entry.deadline )
            {
                entry.setException( new ConnectException("") );
                key.cancel();
                try {
                    key.channel().close();
                } catch( Exception e ) {
                    ExceptionMonitor.getInstance().exceptionCaught( e );
                }
            }

I close the issue as soon as i have tested the official fix.

> 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

Reply via email to