From c43b9b4dd259412f3fa3c950f41658d74b1d84d7 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 23 Oct 2012 16:09:59 -0700 Subject: [PATCH] [#662] Fix race in AioEventLoopGroup - Fix a bug where shutdown() blocks indefinitely sometimes --- .../java/io/netty/channel/socket/aio/AioEventLoopGroup.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/transport/src/main/java/io/netty/channel/socket/aio/AioEventLoopGroup.java b/transport/src/main/java/io/netty/channel/socket/aio/AioEventLoopGroup.java index 501eed3f9a..847cd7e8a5 100644 --- a/transport/src/main/java/io/netty/channel/socket/aio/AioEventLoopGroup.java +++ b/transport/src/main/java/io/netty/channel/socket/aio/AioEventLoopGroup.java @@ -78,7 +78,11 @@ public class AioEventLoopGroup extends MultithreadEventLoopGroup { boolean interrupted = false; // Tell JDK not to accept any more registration request. Note that the threads are not really shut down yet. - group.shutdown(); + try { + group.shutdownNow(); + } catch (IOException e) { + throw new EventLoopException("failed to shut down a channel group", e); + } // Wait until JDK propagates the shutdown request on AsynchronousChannelGroup to the ExecutorService. // JDK will probably submit some final tasks to the ExecutorService before shutting down the ExecutorService,