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

Trustin Lee (JIRA) jira-events at lists.jboss.org
Mon Nov 30 17:05:29 EST 2009


    [ https://jira.jboss.org/jira/browse/NETTY-256?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12497330#action_12497330 ] 

Trustin Lee commented on NETTY-256:
-----------------------------------

NioServerSocketShutdownTimeTest now passes - I made sure the relevant selector is waken up.

> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the netty-dev mailing list