Simplifying Netty application shutdown

"이희승 (Trustin Lee)" trustin at gmail.com
Mon Jan 31 03:26:13 EST 2011


As Bruno already mentioned in his blog post, hanging
releaseExternalResources() is a frustrating issue for a Netty user:

    http://goo.gl/Lfga7

To address this issue, Bruno proposed to modify the behavior of
ChannelGroup so that ChannelGroup.add() rejects a new channel once
ChannelGroup.close() is called.

There are a couple ways to fix this issue in my opinion.  Bruno's idea
is OK, but it leaves us a question about what we should do about other
operations like unbind() and disconnect().

For TCP/IP, unbind(), disconnect(), and close() have the same effect,
but for UDP, they are different in that UDP channels can be disconnected
and then reconnected or unbound and then bound to another address.  If a
user calls disconnect() to a group of TCP/IP channels, a user will still
experience a race condition (i.e. hanging releaseExternalResources()).
Making unbind() and disconnect() reject add() will not be a sensible
behavior to UDP/IP channels, either.

Instead of making it complex, I'd rather like to remove not so commonly
used operations like unbind() and disconnect() from ChannelGroup and
make its behavior easily understood without an exception.

Another change I want to make is to make an I/O thread call
Channel.close() on all open channels when the ExecutorService it is
running on is terminating.  Unless a user intercepts the close()
operation, connections will be terminated automatically on shutdown
request.  Otherwise (e.g. a user intercepts close() request and sends a
good-bye message), a user will have to make sure the connection is
closed as before.

The two proposed changes above seems to me like more sensible default to
me, and I'd like to implement them in 4.0 real soon.  Any feed back is
appreciated.

Cheers,
Trustin

-- 
Trustin Lee, http://gleamynode.net/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 294 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20110131/d675d3d7/attachment.bin 


More information about the netty-users mailing list