From 791c38befe1885cad549460a4de6d9d0b5d5cc68 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 4 Apr 2014 15:22:06 +0200 Subject: [PATCH] [#2359] EpollSocketChannel.remoteAddress0() is always null on accepted EpollSocketChannels Motivation: EpollSocketChannel.remoteAddress0() is always null on accepted EpollSocketChannels as we not set it excplicit. Modifications: Correctly retrieve the local and remote address when accept new channel and store it Result: EpollSocketchannel.remoteAddress0() and EpollSocketChannel.localAddress0() return correct addresses --- .../java/io/netty/channel/epoll/EpollSocketChannel.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollSocketChannel.java b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollSocketChannel.java index 40969464cd..e89b3a0f84 100644 --- a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollSocketChannel.java +++ b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollSocketChannel.java @@ -66,9 +66,13 @@ public final class EpollSocketChannel extends AbstractEpollChannel implements So private volatile boolean inputShutdown; private volatile boolean outputShutdown; - EpollSocketChannel(Channel parent, int fd) { + EpollSocketChannel(Channel parent, int fd) throws IOException { super(parent, fd, Native.EPOLLIN, true); config = new EpollSocketChannelConfig(this); + // Directly cache the remote and local addresses + // See https://github.com/netty/netty/issues/2359 + remote = Native.remoteAddress(fd); + local = Native.localAddress(fd); } public EpollSocketChannel() {