[JBoss JIRA] Closed: (NETTY-256) A race condition during the recommended server shutdown procedure

Thomas Bocek bocek at ifi.uzh.ch
Mon Nov 30 07:58:33 EST 2009


Hi,

I'll check if this is related to my issue as soon as possible, I'm quite
busy these days...

Thomas

Trustin Lee (JIRA) wrote:
>      [ https://jira.jboss.org/jira/browse/NETTY-256?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
> 
> Trustin Lee closed NETTY-256.
> -----------------------------
> 
>     Resolution: Done
> 
> 
> Fixed at revision 1942 - http://fisheye.jboss.org/changelog/Netty/?cs=1942
> 
>> A race condition during the recommended server shutdown procedure
>> -----------------------------------------------------------------
>>
>>                 Key: NETTY-256
>>                 URL: https://jira.jboss.org/jira/browse/NETTY-256
>>             Project: Netty
>>          Issue Type: Bug
>>          Components: Transport
>>            Reporter: Trustin Lee
>>            Assignee: Trustin Lee
>>             Fix For: 3.2.0.ALPHA2
>>
>>
>> The recommended shutdown procedure, as documented, is:
>> 1) Close the server socket (ServerSocketChannel.close().awaitUninterruptibly())
>> 2) Close all open channels (preferably using ChannelGroup.close().awaitUninterruptibly())
>> 3) Call ServerSocketChannelFactory.releaseExternalResources()
>> However, there is a race condition between the step 1 and 2:
>> [Boss thread] accepts a new connections from a client.
>> [User thread] ServerSocketChannel.close().awaitUninterruptibly() succeeds
>> [User thread] ChannelGroup.close() is called and all connections in the group are closed.
>> [Boss thread] triggers channelOpen/Bound/Connected event for the newly accepted channel
>> [Boss thread] the newly accepted channel is added to the ChannelGroup, but it's too late
>> [User thread] ServerSocketChannelFactory.releaseExternalResources() is called, but this is unexpected because there is still an active connection.
>> A workaround is to wait for the boss thread to be terminated or returned to the thread pool (e.g. wait for the termination of the boss thread between the step 1 and 2).  The proper fix is to make sure that the ChannelFuture returned by ServerSocketChannel.unbind/close() are notified *after* the boss thread is completely terminated.
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-dev/attachments/20091130/e2122c60/attachment-0001.bin 


More information about the netty-dev mailing list