From 614323e13239d814ef5c30ad79a03a96d46b4bbc Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Tue, 1 Sep 2020 14:10:39 +0200 Subject: [PATCH] Fix failure during accept(...) Motivation: Sometimes accept failed as we not correctly set the active variable when constructing the server channel. This lead to the situation that we tried to add POLLIN before the channel become active and so tried to call accept before it was listen. Modifications: - Use the correct constructor - Cleanup Result: No more accept failures. --- .../io/netty/channel/uring/AbstractIOUringChannel.java | 2 +- .../channel/uring/AbstractIOUringServerChannel.java | 8 ++------ .../netty/channel/uring/IOUringServerSocketChannel.java | 9 +-------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/transport-native-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringChannel.java b/transport-native-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringChannel.java index 775ae25a9a..4fb09c879f 100644 --- a/transport-native-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringChannel.java +++ b/transport-native-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringChannel.java @@ -56,7 +56,7 @@ import static io.netty.channel.unix.UnixChannelUtil.*; import static io.netty.util.internal.ObjectUtil.*; abstract class AbstractIOUringChannel extends AbstractChannel implements UnixChannel { - private static final InternalLogger logger = InternalLoggerFactory.getInstance(AbstractIOUringChannel.class); + static final InternalLogger logger = InternalLoggerFactory.getInstance(AbstractIOUringChannel.class); private static final ChannelMetadata METADATA = new ChannelMetadata(false); final LinuxSocket socket; protected volatile boolean active; diff --git a/transport-native-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringServerChannel.java b/transport-native-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringServerChannel.java index 07b2a0f042..4d1cd505ba 100644 --- a/transport-native-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringServerChannel.java +++ b/transport-native-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringServerChannel.java @@ -29,12 +29,8 @@ import static io.netty.channel.unix.Errors.*; abstract class AbstractIOUringServerChannel extends AbstractIOUringChannel implements ServerChannel { - AbstractIOUringServerChannel(int fd) { - super(null, new LinuxSocket(fd)); - } - - AbstractIOUringServerChannel(LinuxSocket fd) { - super(null, fd); + protected AbstractIOUringServerChannel(LinuxSocket socket, boolean active) { + super(null, socket, active); } @Override diff --git a/transport-native-io_uring/src/main/java/io/netty/channel/uring/IOUringServerSocketChannel.java b/transport-native-io_uring/src/main/java/io/netty/channel/uring/IOUringServerSocketChannel.java index a603aa204c..14ebe7292f 100644 --- a/transport-native-io_uring/src/main/java/io/netty/channel/uring/IOUringServerSocketChannel.java +++ b/transport-native-io_uring/src/main/java/io/netty/channel/uring/IOUringServerSocketChannel.java @@ -18,22 +18,15 @@ package io.netty.channel.uring; import io.netty.channel.Channel; import io.netty.channel.socket.ServerSocketChannel; import io.netty.channel.unix.FileDescriptor; -import io.netty.channel.unix.Socket; -import java.io.IOException; -import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketAddress; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; public final class IOUringServerSocketChannel extends AbstractIOUringServerChannel implements ServerSocketChannel { private final IOUringServerSocketChannelConfig config; - private volatile Collection tcpMd5SigAddresses = Collections.emptyList(); public IOUringServerSocketChannel() { - super(Socket.newSocketStream().intValue()); + super(LinuxSocket.newSocketStream(), false); this.config = new IOUringServerSocketChannelConfig(this); }