From 4e33b4be3badfa2679054df3ee139a4deb19d983 Mon Sep 17 00:00:00 2001 From: Scott Mitchell Date: Tue, 6 Oct 2015 11:32:44 -0700 Subject: [PATCH] EPOLL Shutdown Input Half Closed Motivation: EPOLL attempts to support half closed socket, but fails to call shutdown to close the read portion of the file descriptor. Motivation: - If half closed is supported shutting down the input should call underlying Native.shutdown(...) to make sure the peer is notified of the half closed state. Result: EPOLL half closed is more correct. --- .../io/netty/channel/epoll/AbstractEpollChannel.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 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 a741a13acf..8e751d16f5 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 @@ -357,8 +357,14 @@ abstract class AbstractEpollChannel extends AbstractChannel implements UnixChann inputShutdown = true; if (isOpen()) { if (Boolean.TRUE.equals(config().getOption(ChannelOption.ALLOW_HALF_CLOSURE))) { - clearEpollIn0(); - pipeline().fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE); + try { + Native.shutdown(fd().intValue(), true, false); + clearEpollIn0(); + pipeline().fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE); + } catch (IOException e) { + pipeline().fireExceptionCaught(e); + close(voidPromise()); + } } else { close(voidPromise()); }