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

ioSession.close().join() when SO_LINGERING set

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 0.9.4, 0.9.5, 1.0.0
    • 1.0.2
    • None
    • None
    • FC5 + Sun JDK 1.5.0_07 (also with _08 and JDK 6 b2)
      CentOS 3.7 + Sun JDK 1.5.0_07
      SUSE 9.1 + Sun JDK 1.5.0_07
      Windows XP SP2 + Sun JDK 1.5.0_08

    Description

      ioSession.close().join() with SO_LINGERING set behaves completely differently on Windows and Linux.

      On a linux machine (acting as the server) when a disconnection occurs (say you pull the plug on the client machine) and depending on the value set for the SO_LINGERING the whole server will block for as long as the value specified in the SO_LINGERING.
      As far as I can tell it gets stuck in the lock.wait() of the IoFuture because it's not ready.

      /**

      • Wait for the asynchronous operation to end.
        */
        public void join()
        {
        synchronized( lock )
        {
        while( !ready )
        {
        try { lock.wait(); }

        catch( InterruptedException e )
        {
        }
        }
        }
        }

      Running the same server code on a Windows machine, it doesn't block.

      Here is a full thread dump:

      Full thread dump Java HotSpot(TM) Server VM (1.5.0_07-b03 mixed mode):

      "PooledByteBufferExpirer-0" daemon prio=1 tid=0x08dfa180 nid=0xa90
      waiting on condition [0x8b479000..0x8b479fc0]
      at java.lang.Thread.sleep(Native Method)
      at org.apache.mina.common.PooledByteBufferAllocator
      $Expirer.run(PooledByteBufferAllocator.java:289)

      "AnonymousIoService-2-2" daemon prio=1 tid=0x08b5a780 nid=0xa8f in
      Object.wait() [0x8b4fa000..0x8b4fb040]
      at java.lang.Object.wait(Native Method)

      • waiting on <0xae623b98> (a org.apache.mina.util.BlockingQueue)
        at java.lang.Object.wait(Object.java:474)
        at
        org.apache.mina.util.BlockingQueue.waitForNewItem(BlockingQueue.java:55)
      • locked <0xae623b98> (a org.apache.mina.util.BlockingQueue)
        at org.apache.mina.filter.ThreadPoolFilter
        $Worker.fetchBuffer(ThreadPoolFilter.java:447)
      • locked <0xae623b98> (a org.apache.mina.util.BlockingQueue)
        at org.apache.mina.filter.ThreadPoolFilter
        $Worker.run(ThreadPoolFilter.java:422)

      "SocketAcceptorIoProcessor-0.0" prio=1 tid=0x08b5b808 nid=0xa8c runnable
      [0x8b57b000..0x8b57c0c0]
      at sun.nio.ch.FileDispatcher.preClose0(Native Method)
      at sun.nio.ch.SocketDispatcher.preClose(SocketDispatcher.java:41)
      at
      sun.nio.ch.SocketChannelImpl.implCloseSelectableChannel(SocketChannelImpl.java:626)

      • locked <0xae6b1418> (a java.lang.Object)
        at
        java.nio.channels.spi.AbstractSelectableChannel.implCloseChannel(AbstractSelectableChannel.java:201)
        at
        java.nio.channels.spi.AbstractInterruptibleChannel.close(AbstractInterruptibleChannel.java:97)
      • locked <0xae6b13f0> (a java.lang.Object)
        at
        org.apache.mina.transport.socket.nio.SocketIoProcessor.doRemove(SocketIoProcessor.java:217)
        at org.apache.mina.transport.socket.nio.SocketIoProcessor.access
        $600(SocketIoProcessor.java:41)
        at org.apache.mina.transport.socket.nio.SocketIoProcessor
        $Worker.run(SocketIoProcessor.java:569)

      "AnonymousIoService-2-1" daemon prio=1 tid=0x08b5b330 nid=0xa8b in
      Object.wait() [0x8b5fc000..0x8b5fd140]
      at java.lang.Object.wait(Native Method)

      • waiting on <0xae6f2a48> (a java.lang.Object)
        at org.apache.mina.filter.ThreadPoolFilter
        $Worker.waitForPromotion(ThreadPoolFilter.java:546)
      • locked <0xae6f2a48> (a java.lang.Object)
        at org.apache.mina.filter.ThreadPoolFilter
        $Worker.run(ThreadPoolFilter.java:419)

      "DestroyJavaVM" prio=1 tid=0x086293d0 nid=0xa64 waiting on condition
      [0x00000000..0xbf831bb0]

      "SocketAcceptor-1" prio=1 tid=0x089bb9f0 nid=0xa85 runnable
      [0x8b67d000..0x8b67e1c0]
      at sun.nio.ch.PollArrayWrapper.poll0(Native Method)
      at sun.nio.ch.PollArrayWrapper.poll(PollArrayWrapper.java:100)
      at sun.nio.ch.PollSelectorImpl.doSelect(PollSelectorImpl.java:56)
      at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)

      • locked <0xae676e58> (a sun.nio.ch.Util$1)
      • locked <0xae676e48> (a java.util.Collections$UnmodifiableSet)
      • locked <0xae676c50> (a sun.nio.ch.PollSelectorImpl)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:84)
        at org.apache.mina.transport.socket.nio.SocketAcceptor
        $Worker.run(SocketAcceptor.java:355)

      "Timer-1" prio=1 tid=0x08dfc528 nid=0xa84 in Object.wait()
      [0x8b6fe000..0x8b6fee40]
      at java.lang.Object.wait(Native Method)

      • waiting on <0xae6766c0> (a java.util.TaskQueue)
        at java.lang.Object.wait(Object.java:474)
        at java.util.TimerThread.mainLoop(Timer.java:483)
      • locked <0xae6766c0> (a java.util.TaskQueue)
        at java.util.TimerThread.run(Timer.java:462)

      "SocketAcceptor-0" prio=1 tid=0x0902ac68 nid=0xa83 runnable
      [0x8b8fe000..0x8b8feec0]
      at sun.nio.ch.PollArrayWrapper.poll0(Native Method)
      at sun.nio.ch.PollArrayWrapper.poll(PollArrayWrapper.java:100)
      at sun.nio.ch.PollSelectorImpl.doSelect(PollSelectorImpl.java:56)
      at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)

      • locked <0xae660a28> (a sun.nio.ch.Util$1)
      • locked <0xae660a18> (a java.util.Collections$UnmodifiableSet)
      • locked <0xae660668> (a sun.nio.ch.PollSelectorImpl)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:84)
        at org.apache.mina.transport.socket.nio.SocketAcceptor
        $Worker.run(SocketAcceptor.java:355)

      "Session Manager" prio=1 tid=0x8b781740 nid=0xa82 runnable
      [0x8bafe000..0x8bafef40]
      at
      com.threegscene.arg.gp.session.AbstractSessionSink.closeIoSession(AbstractSessionSink.java:122)
      at
      com.threegscene.arg.gp.session.DefaultSession.setConnected(DefaultSession.java:286)
      at
      com.threegscene.arg.gp.session.SessionManager.scan(SessionManager.java:215)
      at com.threegscene.arg.gp.session.SessionManager.access
      $0(SessionManager.java:172)
      at com.threegscene.arg.gp.session.SessionManager
      $1.run(SessionManager.java:108)
      at java.util.TimerThread.mainLoop(Timer.java:512)
      at java.util.TimerThread.run(Timer.java:462)

      "RMI TCP Accept-20702" daemon prio=1 tid=0x8c1d5720 nid=0xa7f runnable
      [0x8bd0b000..0x8bd0c040]
      at java.net.PlainSocketImpl.socketAccept(Native Method)
      at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)

      • locked <0x919c3140> (a java.net.SocksSocketImpl)
        at java.net.ServerSocket.implAccept(ServerSocket.java:450)
        at java.net.ServerSocket.accept(ServerSocket.java:421)
        at sun.rmi.transport.tcp.TCPTransport.run(TCPTransport.java:340)
        at java.lang.Thread.run(Thread.java:595)

      "RMI TCP Accept-0" daemon prio=1 tid=0x8c1d08f0 nid=0xa7e runnable
      [0x8bd8c000..0x8bd8d0c0]
      at java.net.PlainSocketImpl.socketAccept(Native Method)
      at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)

      • locked <0x919c30c8> (a java.net.SocksSocketImpl)
        at java.net.ServerSocket.implAccept(ServerSocket.java:450)
        at java.net.ServerSocket.accept(ServerSocket.java:421)
        at sun.rmi.transport.tcp.TCPTransport.run(TCPTransport.java:340)
        at java.lang.Thread.run(Thread.java:595)

      "Timer-0" daemon prio=1 tid=0x8c1ce8f8 nid=0xa7d in Object.wait()
      [0x8be0d000..0x8be0e140]
      at java.lang.Object.wait(Native Method)

      • waiting on <0x919c31b8> (a java.util.TaskQueue)
        at java.lang.Object.wait(Object.java:474)
        at java.util.TimerThread.mainLoop(Timer.java:483)
      • locked <0x919c31b8> (a java.util.TaskQueue)
        at java.util.TimerThread.run(Timer.java:462)

      "Low Memory Detector" daemon prio=1 tid=0x086e6f28 nid=0xa7c runnable
      [0x00000000..0x00000000]

      "CompilerThread1" daemon prio=1 tid=0x086e59a0 nid=0xa7b waiting on
      condition [0x00000000..0x8cee2068]

      "CompilerThread0" daemon prio=1 tid=0x086e4840 nid=0xa7a waiting on
      condition [0x00000000..0x8cf63028]

      "AdapterThread" daemon prio=1 tid=0x086e32a8 nid=0xa79 waiting on
      condition [0x00000000..0x00000000]

      "Signal Dispatcher" daemon prio=1 tid=0x086e1c38 nid=0xa78 waiting on
      condition [0x00000000..0x00000000]

      "JDWP Command Reader" daemon prio=1 tid=0x086e01d8 nid=0xa73 runnable
      [0x00000000..0x00000000]

      "JDWP Event Helper Thread" daemon prio=1 tid=0x086df158 nid=0xa72
      runnable [0x00000000..0x00000000]

      "JDWP Transport Listener: dt_socket" daemon prio=1 tid=0x086dd668
      nid=0xa71 runnable [0x00000000..0x8d1e8e80]

      "Finalizer" daemon prio=1 tid=0x086cceb0 nid=0xa6e in Object.wait()
      [0x8d46a000..0x8d46a1c0]
      at java.lang.Object.wait(Native Method)

      • waiting on <0x9195c2e8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
      • locked <0x9195c2e8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

      "Reference Handler" daemon prio=1 tid=0x086cc918 nid=0xa6d in
      Object.wait() [0x8d4ea000..0x8d4eae40]
      at java.lang.Object.wait(Native Method)

      • waiting on <0x91970bb0> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:474)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
      • locked <0x91970bb0> (a java.lang.ref.Reference$Lock)

      "VM Thread" prio=1 tid=0x086ca488 nid=0xa6c runnable

      "GC task thread#0 (ParallelGC)" prio=1 tid=0x086431e0 nid=0xa6a
      runnable

      "GC task thread#1 (ParallelGC)" prio=1 tid=0x08643e30 nid=0xa6b
      runnable

      "VM Periodic Task Thread" prio=1 tid=0x8c1d99d8 nid=0xa80 waiting on
      condition

      Attachments

        Activity

          People

            trustin Trustin Lee
            fsoulier Frederic Soulier
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: