[ 
https://issues.apache.org/jira/browse/DIRMINA-514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12573170#action_12573170
 ] 

Justin SB commented on DIRMINA-514:
-----------------------------------

I've got this happening in my application also, on Mac OS X Leopard 10.5.2.

I've verified that MINA seems to be doing the right thing, in that the destroy 
function of NioProcessor is called and seems to execute OK.  .close is called 
on the channel, no exception is thrown, and the channel moves into the closed 
state.  However, the socket does remain open (I've only tested loopback).

For reference, the destroy function is below.

@Override
    protected void destroy(NioSession session) throws Exception {
        ByteChannel ch = session.getChannel();
        SelectionKey key = session.getSelectionKey();
        if (key != null) {
            key.cancel();
        }
        ch.close();
    }

ch is a java.nio.channels.SocketChannel.  After the close statement, toString() 
gives java.nio.channels.SocketChannel[closed]

I haven't found any references to this as a known bug.  I would think that if 
it were a bug in the Mac OS, that these problems would be visible in every 
application that uses NIO, but I can't think what could be different here.

Following the Tomcat example, I tried explicitly closing the socket:
protected void destroy(NioSession session) throws Exception {
        ByteChannel ch = session.getChannel();
        SelectionKey key = session.getSelectionKey();
        if (key != null) {
            key.cancel();
        }
        if (ch instanceof SocketChannel) {
                        SocketChannel sc = (SocketChannel) ch;
                        Socket socket = sc.socket();
                        socket.close();
                        System.out.println(socket.isClosed());
                }
        ch.close();
    }

But that doesn't improve matters: socket.isClosed() is true, but the socket 
remains open.

netstat shows the socket to be in state ESTABLISHED (on both legs, as this is 
localhost).

I think, but am not certain, that this only applies to channels where we are 
the server, if that provides a clue to anyone.

> Session closing problem on Mac OS X
> -----------------------------------
>
>                 Key: DIRMINA-514
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-514
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0-M1
>         Environment: Mac OS X 10.4 with Java 1.5.0_07 -87
>            Reporter: Matteo Merli
>         Attachments: Echo1_1.java, Echo2_0.java
>
>
> A call to session.close() does not send a FIN packet althought MINA will 
> considers the session as closed.
> I've attached two test cases, one that works with MINA 1.1 (and works fine) 
> and other with MINA 2.0 that doesn't close connections.
> This is a simple echo server that receives a message, writes it back to the 
> client and (should) close the connection. 
> This problem is *NOT* ocurring on Linux where the same test case works fine. 
> It only shows up on Mac OS X.

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