Thanks. It works. I believe this would also reduce the time that my
connection thread would wait for the session to be established?
Though I have not looked in to the code, but I was curious as to why the
timeout timer can not be killed if it has determined that the connection can
not be established (as it releases the threads which have joined
ConnectFuture and ConnectFuture gives indication that connection can not be
established)? If that is doable, then the thread would not wait for it to
time out and can release resources immediately.
Thanks,
Akbar.
Trustin Lee wrote:
>
> I see. Please try to set the workerTimeout property of SocketConnector to
> smaller value.
>
> connector.setWorkerTimeout(5); // 5 seconds
>
> Then it will terminate in 5 seconds.
>
> HTH,
> Trustin
>
> On 1/21/07, Akbar Munir <[EMAIL PROTECTED]> wrote:
>>
>>
>> Below is the full thread dump. This thread dump is for JDK 6 VM with
>> Apache
>> MINA 1.0.1, recompiled on JDK 6 and all backport references changed to
>> java.util.concurrent.
>>
>> ----------------------------------- THREAD DUMP START
>> ---------------------------------
>> 2007-01-21 18:58:37
>> Full thread dump Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode,
>> sharing):
>>
>> "StackTrace Remote Thread" prio=6 tid=0x02a65400 nid=0xddc runnable
>> [0x00000000..0x033cfb88]
>> java.lang.Thread.State: RUNNABLE
>>
>> "DestroyJavaVM" prio=6 tid=0x00296400 nid=0xcfc waiting on condition
>> [0x00000000..0x0090fd4c]
>> java.lang.Thread.State: RUNNABLE
>>
>> "SocketConnector-0" prio=6 tid=0x02de2800 nid=0x1058 runnable
>> [0x032df000..0x032dfb94]
>> java.lang.Thread.State: RUNNABLE
>> at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native
>> Method)
>> at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(Unknown
>> Source)
>> at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(Unknown
>> Source)
>> at sun.nio.ch.WindowsSelectorImpl.doSelect(Unknown Source)
>> at sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source)
>> - locked <0x229c4ea8> (a sun.nio.ch.Util$1)
>> - locked <0x229c4e98> (a java.util.Collections$UnmodifiableSet)
>> - locked <0x229c4ac0> (a sun.nio.ch.WindowsSelectorImpl)
>> at sun.nio.ch.SelectorImpl.select(Unknown Source)
>> at
>> org.apache.mina.transport.socket.nio.SocketConnector$Worker.run(
>> SocketConnector.java:408)
>> at
>> org.apache.mina.util.NamePreservingRunnable.run(
>> NamePreservingRunnable.java:43)
>> at java.lang.Thread.run(Unknown Source)
>>
>> "Low Memory Detector" daemon prio=6 tid=0x02a7d000 nid=0x1018 runnable
>> [0x00000000..0x00000000]
>> java.lang.Thread.State: RUNNABLE
>>
>> "CompilerThread0" daemon prio=10 tid=0x02a78000 nid=0x16d8 waiting on
>> condition [0x00000000..0x02d2f69c]
>> java.lang.Thread.State: RUNNABLE
>>
>> "Attach Listener" daemon prio=10 tid=0x02a77000 nid=0x10cc runnable
>> [0x00000000..0x00000000]
>> java.lang.Thread.State: RUNNABLE
>>
>> "Signal Dispatcher" daemon prio=10 tid=0x02a76000 nid=0x710 runnable
>> [0x00000000..0x00000000]
>> java.lang.Thread.State: RUNNABLE
>>
>> "Finalizer" daemon prio=8 tid=0x02a71800 nid=0x1088 in Object.wait()
>> [0x02c3f000..0x02c3fa14]
>> java.lang.Thread.State: WAITING (on object monitor)
>> at java.lang.Object.wait(Native Method)
>> - waiting on <0x22a802b0> (a java.lang.ref.ReferenceQueue$Lock)
>> at java.lang.ref.ReferenceQueue.remove(Unknown Source)
>> - locked <0x22a802b0> (a java.lang.ref.ReferenceQueue$Lock)
>> at java.lang.ref.ReferenceQueue.remove(Unknown Source)
>> at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
>>
>> "Reference Handler" daemon prio=10 tid=0x02a6d400 nid=0x1530 in
>> Object.wait() [0x02bef000..0x02befb14]
>> java.lang.Thread.State: WAITING (on object monitor)
>> at java.lang.Object.wait(Native Method)
>> - waiting on <0x22a80340> (a java.lang.ref.Reference$Lock)
>> at java.lang.Object.wait(Object.java:485)
>> at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
>> - locked <0x22a80340> (a java.lang.ref.Reference$Lock)
>>
>> "VM Thread" prio=10 tid=0x02a64000 nid=0x360 runnable
>>
>> "VM Periodic Task Thread" prio=10 tid=0x02a7e400 nid=0x1508 waiting on
>> condition
>>
>> ------------------------------------------------------ THREAD DUMP END
>> ---------------------------------
>>
>> Trustin Lee wrote:
>> >
>> > Please attach the full thread dump.
>> >
>> > Trustin
>> >
>> >
>> > On 1/20/07, Akbar Munir <[EMAIL PROTECTED]> wrote:
>> >>
>> >>
>> >> I have noticed that in my program, even when MINA is not able to
>> connect
>> >> to
>> >> remote peer, the program does not exit. It appears that there are some
>> >> open
>> >> resources which are required to be closed explicitly. The code is at
>> the
>> >> end
>> >> of this email. The program prints "false", as no server is running,
>> but
>> >> after that does not exits. Any idea which resources are still open? I
>> >> have
>> >> tried this with both Java 5 and Java 6 and behavior is the same.
>> >>
>> >> Thanks,
>> >> Akbar.
>> >>
>> >> --------------------------------- START --------------------------
>> >> public static void main(String[] a_strArrayOfArguments)
>> >> {
>> >> ConnectFuture oConnectFuture = new
>> SocketConnector().connect(new
>> >> InetSocketAddress("localhost", 1234), new IoHandlerAdapter());
>> >>
>> >> oConnectFuture.join();
>> >>
>> >> System.out.println("Result = " + oConnectFuture.isConnected());
>> >> }
>> >> ------------------------------- END
>> >> -----------------------------------------
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Program-does-not-exit-possible-due-to-open-resources-tf3045115.html#a8464526
>> >> Sent from the mina dev mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > what we call human nature is actually human habit
>> > --
>> > http://gleamynode.net/
>> > --
>> > PGP key fingerprints:
>> > * E167 E6AF E73A CBCE EE41 4A29 544D DE48 FE95 4E7E
>> > * B693 628E 6047 4F8F CFA4 455E 1C62 A7DC 0255 ECA6
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Program-does-not-exit-possible-due-to-open-resources-tf3045115.html#a8475159
>> Sent from the mina dev mailing list archive at Nabble.com.
>>
>>
>
>
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP key fingerprints:
> * E167 E6AF E73A CBCE EE41 4A29 544D DE48 FE95 4E7E
> * B693 628E 6047 4F8F CFA4 455E 1C62 A7DC 0255 ECA6
>
>
--
View this message in context:
http://www.nabble.com/Program-does-not-exit-possible-due-to-open-resources-tf3045115.html#a8520078
Sent from the mina dev mailing list archive at Nabble.com.