Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-804

NioDatagramAcceptor.unbind does not unbind cleanly

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.8
    • Component/s: Transport
    • Labels:
      None
    • Environment:
      Windows 7

      Description

      Steps to reproduce:
      1. Use below code.

      NioDatagramAcceptor acceptor = new NioDatagramAcceptor();
      acceptor.setHandler(new IoHandlerAdapter());
      SocketAddress localAddress = new InetSocketAddress("localhost",9001);
      acceptor.bind(localAddress);
      acceptor.unbind(localAddress);
      

      2. use debugger to step over here after unbind() call but before exiting the process
      3. use netstat to check current UDP sockets. you can find port 9001 not released yet.

      Possible solution: invoke selector.selectNow() after closing the channel.

       @Override
          protected void close(DatagramChannel handle) throws Exception {
              SelectionKey key = handle.keyFor(selector);
      
              if (key != null) {
                  key.cancel();
              }
              
              handle.disconnect();
              handle.close();
              selector.selectNow();
          }
      

        Activity

        Hide
        elecharny Emmanuel Lecharny added a comment -

        To be investigated

        Show
        elecharny Emmanuel Lecharny added a comment - To be investigated
        Hide
        sorhed Alexander Temerev added a comment -

        I can confirm this bug happening both on Ubuntu Server and Mac OS X. Very annoying, actually, because I cannot restart my production server for minutes.

        Show
        sorhed Alexander Temerev added a comment - I can confirm this bug happening both on Ubuntu Server and Mac OS X. Very annoying, actually, because I cannot restart my production server for minutes.
        Hide
        elecharny Emmanuel Lecharny added a comment -

        In 2.0.7, the datagram is closed as soon as the unbind is done (I did the test). The pb should have been fixed a while ago, or this is a typical Windows 7 issue.

        Show
        elecharny Emmanuel Lecharny added a comment - In 2.0.7, the datagram is closed as soon as the unbind is done (I did the test). The pb should have been fixed a while ago, or this is a typical Windows 7 issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            zzhou Zhou
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development