You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by afa654321 <af...@yahoo.com> on 2007/02/28 03:24:38 UTC

session.close()

Hi All,

I have written a simple client test application which does *not* terminate
after executing the following:

session.close(); 
System.exit(0);

I see, after the exit statement is executed, the following runnable thread:

Thread [PooledByteBufferExpirer-0] (Running)
Thread [SocketConnector-1] (Running)

"Thread [SocketConnector-1] (Running)" dies after a few seconds.

Why doesn't the "Thread [PooledByteBufferExpirer-0] (Running)" terminate?
and subsequently the program?

Thx.


-- 
View this message in context: http://www.nabble.com/session.close%28%29-tf3306314.html#a9196899
Sent from the mina dev mailing list archive at Nabble.com.


Re: session.close()

Posted by Trustin Lee <tr...@gmail.com>.
On 3/24/07, EricFitchett <er...@ericfitchett.com> wrote:
>
> Any luck?
> I'm running into the same issue with the following VM:
> Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
>
> Running on Ubuntu 6.06, tried under eclipse and with the command line.
> Occurs with Mina 1.0.1 and 1.0.2 releases.
>
> I decided to try to pare down my code to the minimum required to duplicate
> the problem.
> I made a simple class with both a JUnit test case and a main method.  The
> interesting part is that the JUnit test works (and terminates the process),
> but the main method (which calls the same code) leaves the process running.
> Also, the mina examples work fine (Tennis, etc), which makes me think I've
> got to be doing something wrong - but there's not a lot of code for there to
> be a problem in.
>
> Here's my code:
> import java.net.InetSocketAddress;
> import junit.framework.TestCase;
> import org.apache.mina.common.ConnectFuture;
> import org.apache.mina.common.IoHandlerAdapter;
> import org.apache.mina.transport.socket.nio.SocketConnector;
>
> public final class MinaClientTest extends TestCase {
>         public static void main(String[] args) {
>                 new MinaClientTest().testClientClose();
>         }
>         public void testClientClose() {
>                 SocketConnector connector = new SocketConnector();
>                 ConnectFuture connectFuture = connector.connect(
>                                 new InetSocketAddress("www.google.com", 80),
>                                 new IoHandlerAdapter() {});
>                 connectFuture.join();
>                 connectFuture.getSession().close().join();
>                 System.out.println("Session closed");
>         }
> }

You will have to set workerTimeout property to smaller value.  For example,

connector.setWorkerTimeout(5);  // 5 seconds

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: session.close()

Posted by EricFitchett <er...@EricFitchett.com>.
Any luck?
I'm running into the same issue with the following VM:
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)

Running on Ubuntu 6.06, tried under eclipse and with the command line. 
Occurs with Mina 1.0.1 and 1.0.2 releases.

I decided to try to pare down my code to the minimum required to duplicate
the problem.
I made a simple class with both a JUnit test case and a main method.  The
interesting part is that the JUnit test works (and terminates the process),
but the main method (which calls the same code) leaves the process running.
Also, the mina examples work fine (Tennis, etc), which makes me think I've
got to be doing something wrong - but there's not a lot of code for there to
be a problem in.

Here's my code:
import java.net.InetSocketAddress;
import junit.framework.TestCase;
import org.apache.mina.common.ConnectFuture;
import org.apache.mina.common.IoHandlerAdapter;
import org.apache.mina.transport.socket.nio.SocketConnector;

public final class MinaClientTest extends TestCase {
	public static void main(String[] args) {
		new MinaClientTest().testClientClose();
	}
	public void testClientClose() {
		SocketConnector connector = new SocketConnector();
		ConnectFuture connectFuture = connector.connect(
				new InetSocketAddress("www.google.com", 80),
				new IoHandlerAdapter() {});
		connectFuture.join();
		connectFuture.getSession().close().join();
		System.out.println("Session closed");
	}
}

Thanks in advance for any help!

-Eric Fitchett


afa654321 wrote:
> 
> Thx Trustin.
> 
> JVM is:
> 
> Java HotSpot(TM) 64-Bit Server VM (build 1.6.0-rc-b103, mixed mode)
> Has anybody else experienced similar behavior?
> 
> I'll look into it further.
> 
> 

-- 
View this message in context: http://www.nabble.com/session.close%28%29-tf3306314.html#a9639309
Sent from the mina dev mailing list archive at Nabble.com.


Re: [VOTE] session.close()

Posted by afa654321 <af...@yahoo.com>.
Thx Trustin.

JVM is:

Java HotSpot(TM) 64-Bit Server VM (build 1.6.0-rc-b103, mixed mode)
Has anybody else experienced similar behavior?

I'll look into it further.


Trustin Lee wrote:
> 
> 2007-02-27 (화), 18:24 -0800, afa654321 쓰시길:
>> Hi All,
>> 
>> I have written a simple client test application which does *not*
>> terminate
>> after executing the following:
>> 
>> session.close(); 
>> System.exit(0);
>> 
>> I see, after the exit statement is executed, the following runnable
>> thread:
>> 
>> Thread [PooledByteBufferExpirer-0] (Running)
>> Thread [SocketConnector-1] (Running)
>> 
>> "Thread [SocketConnector-1] (Running)" dies after a few seconds.
>> 
>> Why doesn't the "Thread [PooledByteBufferExpirer-0] (Running)" terminate?
>> and subsequently the program?
> 
> Well, it's weird!
> 
> It might be because it takes longer to deallocate direct buffers.
> PooledByteBufferExpirer is a daemon thread, so it should exit by itself
> when there's no other non-daemon threads.  Moreover, System.exit() is
> supposed to stop all threads including both daemon and non-daemon
> threads.  So, I suspect JVM.
> 
> Trustin
> -- 
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
> 
>  
> 

-- 
View this message in context: http://www.nabble.com/session.close%28%29-tf3306314.html#a9341365
Sent from the mina dev mailing list archive at Nabble.com.


Re: session.close()

Posted by Trustin Lee <tr...@gmail.com>.
2007-02-27 (화), 18:24 -0800, afa654321 쓰시길:
> Hi All,
> 
> I have written a simple client test application which does *not* terminate
> after executing the following:
> 
> session.close(); 
> System.exit(0);
> 
> I see, after the exit statement is executed, the following runnable thread:
> 
> Thread [PooledByteBufferExpirer-0] (Running)
> Thread [SocketConnector-1] (Running)
> 
> "Thread [SocketConnector-1] (Running)" dies after a few seconds.
> 
> Why doesn't the "Thread [PooledByteBufferExpirer-0] (Running)" terminate?
> and subsequently the program?

Well, it's weird!

It might be because it takes longer to deallocate direct buffers.
PooledByteBufferExpirer is a daemon thread, so it should exit by itself
when there's no other non-daemon threads.  Moreover, System.exit() is
supposed to stop all threads including both daemon and non-daemon
threads.  So, I suspect JVM.

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6