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 334455e162..d7cf28e04b 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 @@ -214,17 +214,20 @@ abstract class AbstractIOUringChannel extends AbstractChannel implements UnixCha freeRemoteAddressMemory(); active = false; - IOUringSubmissionQueue submissionQueue = submissionQueue(); - if ((ioState & POLL_IN_SCHEDULED) != 0) { - submissionQueue.addPollRemove(socket.intValue(), IOUring.POLLMASK_IN); - ioState &= ~POLL_IN_SCHEDULED; + // doClose() may be called by closeForcibly() before the Channel is registered on the EventLoop. + if (isRegistered()) { + IOUringSubmissionQueue submissionQueue = submissionQueue(); + if ((ioState & POLL_IN_SCHEDULED) != 0) { + submissionQueue.addPollRemove(socket.intValue(), IOUring.POLLMASK_IN); + ioState &= ~POLL_IN_SCHEDULED; + } + if ((ioState & POLL_OUT_SCHEDULED) != 0) { + submissionQueue.addPollRemove(socket.intValue(), IOUring.POLLMASK_OUT); + ioState &= ~POLL_OUT_SCHEDULED; + } + submissionQueue.addPollRemove(socket.intValue(), IOUring.POLLMASK_RDHUP); + submissionQueue.submit(); } - if ((ioState & POLL_OUT_SCHEDULED) != 0) { - submissionQueue.addPollRemove(socket.intValue(), IOUring.POLLMASK_OUT); - ioState &= ~POLL_OUT_SCHEDULED; - } - submissionQueue.addPollRemove(socket.intValue(), IOUring.POLLMASK_RDHUP); - submissionQueue.submit(); // Even if we allow half closed sockets we should give up on reading. Otherwise we may allow a read attempt on a // socket which has not even been connected yet. This has been observed to block during unit tests. diff --git a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketCloseForciblyTest.java b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketCloseForciblyTest.java index 626df4274c..4d36ee48bf 100644 --- a/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketCloseForciblyTest.java +++ b/transport-native-io_uring/src/test/java/io/netty/channel/uring/IOUringSocketCloseForciblyTest.java @@ -19,8 +19,6 @@ import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.testsuite.transport.TestsuitePermutation; import io.netty.testsuite.transport.socket.SocketCloseForciblyTest; -import org.junit.Ignore; -import org.junit.Test; import java.util.List; @@ -29,11 +27,4 @@ public class IOUringSocketCloseForciblyTest extends SocketCloseForciblyTest { protected List> newFactories() { return IOUringSocketTestPermutation.INSTANCE.socket(); } - - @Ignore("FIX ME") - @Test - @Override - public void testCloseForcibly() throws Throwable { - super.testCloseForcibly(); - } }