Shutdown of Server Channel Factory

Thomas Bocek bocek at ifi.uzh.ch
Wed Sep 9 13:44:13 EDT 2009


Michael, try this one:

public void stop() {
 logger.log(InternalLogLevel.INFO, this.getClass().getSimpleName()
 + " start stop");
 this.channel.close().awaitUninterruptibly();
 NettyKarmaReceiver.this.factory.releaseExternalResources();
 logger.log(InternalLogLevel.INFO, this.getClass().getSimpleName()
 + " end stop");
}

If you block in the Netty thread, then the close operation is never
finished, and the terminate() call is in an endless loop, resulting in a
deadlock. Either you do it outside the Netty thread as above, or you
create a new Thread and run it there.

Thomas

Michael McGrady wrote:
> Thanks, Thomas.  The following is the code I am using and in this test
> there is no other connection than the one.
> 
> 
> 
>     public void stop() {
>         logger.log(InternalLogLevel.INFO, this.getClass().getSimpleName()
>                 + " start stop");
>         ChannelFuture close = this.channel.close();
>        
>         close.addListener(new ChannelFutureListener() {
> 
>             public void operationComplete(ChannelFuture future)
>                     throws Exception {
>                 NettyKarmaReceiver.this.factory.releaseExternalResources();
> 
>                 logger.log(InternalLogLevel.INFO,
> this.getClass().getSimpleName()
>                         + " end stop");
>             }
>            
>         });
>     }
> 
> 
> 
> On Sep 9, 2009, at 10:09 AM, Thomas Bocek wrote:
> 
>> Michael McGrady wrote:
>>> I am not getting a return from the NeoServerSocketChannelFactory's
>>> releaseExternalResources method.  Is this something anyone else has
>>> seen?  This is very surprising to me because this is just in essence a
>>> return from the ExecutorUtil terminate method which just copies and
>>> shuts down the copies as ExecutorServices shutdown method.  There
>>> should be only a 100 millisecond wait in that method.
>>
>> The awaitTermination() call may return false, so it will wait longer
>> than 100msec.
>>
>>> Any ideas?
>>
>> Make sure you have closed all connections before calling
>> releaseExternalResources. You can use the ChannelGroup to group channels
>> and close them with ChannelGroup.close().
>>
>> Thomas
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
> 
> Mike McGrady
> Principal Investigator AF081-028 AFRL SBIR
> Senior Engineer
> Topia Technology, Inc
> 1.253.720.3365
> mmcgrady at topiatechnology.com
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users


More information about the netty-users mailing list