From d0dc02d82670196f0183582ba4879f012174ce93 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Mon, 29 Aug 2016 12:43:11 +0200 Subject: [PATCH] Correctly guard against NotYetConnectedExceptions when handling RDHUP. Motivation: Commit 2c1f17faa268b9a1b8ef8f1ddaf832d1397719a3 introduced a regression which could cause NotYetConnectedExceptions when handling RDHUP events. Modifications: Correct ignore NotYetConnectedException when handling RDHUP events. Result: No more regression. --- .../channel/epoll/AbstractEpollChannel.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollChannel.java b/transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollChannel.java index b130398bd92e..79b8c052ea02 100644 --- a/transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollChannel.java +++ b/transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollChannel.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.net.InetSocketAddress; import java.nio.ByteBuffer; +import java.nio.channels.NotYetConnectedException; import java.nio.channels.UnresolvedAddressException; import static io.netty.util.internal.ObjectUtil.checkNotNull; @@ -405,19 +406,29 @@ void shutdownInput() { try { fd().shutdown(true, false); clearEpollIn0(); - pipeline().fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE); } catch (IOException ignored) { // We attempted to shutdown and failed, which means the input has already effectively been // shutdown. - pipeline().fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE); - close(voidPromise()); + fireEventAndClose(ChannelInputShutdownEvent.INSTANCE); + return; + } catch (NotYetConnectedException ignore) { + // We attempted to shutdown and failed, which means the input has already effectively been + // shutdown. + fireEventAndClose(ChannelInputShutdownEvent.INSTANCE); + return; } + pipeline().fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE); } else { close(voidPromise()); } } } + private void fireEventAndClose(Object evt) { + pipeline().fireUserEventTriggered(evt); + close(voidPromise()); + } + @Override public EpollRecvByteAllocatorHandle recvBufAllocHandle() { if (allocHandle == null) {