[#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
This commit is contained in:
Norman Maurer 2014-04-04 15:22:06 +02:00
parent fdb1db90c4
commit 791c38befe

View File

@ -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() {