From d02b51965f6b4906ca1f8f9648c2eb801df7b94a Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Mon, 25 Feb 2019 08:55:55 +0100 Subject: [PATCH] Don't deregister Channel as part of closing it when using native kqueue transport (#8881) Motivation: In https://github.com/netty/netty/pull/8665 we changed how we handle the registration of Channels to KQueue but missed to removed some code which would deregister the Channel before it actual closed the underlying socket. This could lead to have events triggered still while not have a mapping to the Channel anymore. Modifications: Remove deregister call during socket closure. Result: Fixes https://github.com/netty/netty/issues/8849. --- .../channel/kqueue/AbstractKQueueChannel.java | 30 +------------------ 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueChannel.java b/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueChannel.java index be07852f37..f44a7f164f 100644 --- a/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueChannel.java +++ b/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueChannel.java @@ -124,35 +124,7 @@ abstract class AbstractKQueueChannel extends AbstractChannel implements UnixChan // Even if we allow half closed sockets we should give up on reading. Otherwise we may allow a read attempt on a // socket which has not even been connected yet. This has been observed to block during unit tests. inputClosedSeenErrorOnRead = true; - try { - if (isRegistered()) { - // The FD will be closed, which should take care of deleting any associated events from kqueue, but - // since we rely upon jniSelfRef to be consistent we make sure that we clear this reference out for - // all events which are pending in kqueue to avoid referencing a deleted pointer at a later time. - - // Need to check if we are on the EventLoop as doClose() may be triggered by the GlobalEventExecutor - // if SO_LINGER is used. - // - // See https://github.com/netty/netty/issues/7159 - EventLoop loop = eventLoop(); - if (loop.inEventLoop()) { - doDeregister(); - } else { - loop.execute(new Runnable() { - @Override - public void run() { - try { - doDeregister(); - } catch (Throwable cause) { - pipeline().fireExceptionCaught(cause); - } - } - }); - } - } - } finally { - socket.close(); - } + socket.close(); } @Override