Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable SocketHalfClosedTest for epoll #13025

Merged
merged 2 commits into from Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -363,7 +363,7 @@ private static void testAutoCloseFalseDoesShutdownOutput(boolean allowHalfClosed
Bootstrap cb) throws InterruptedException {
final int expectedBytes = 100;
final CountDownLatch serverReadExpectedLatch = new CountDownLatch(1);
final CountDownLatch doneLatch = new CountDownLatch(1);
final CountDownLatch doneLatch = new CountDownLatch(2);
final AtomicReference<Throwable> causeRef = new AtomicReference<Throwable>();
Channel serverChannel = null;
Channel clientChannel = null;
Expand All @@ -375,9 +375,9 @@ private static void testAutoCloseFalseDoesShutdownOutput(boolean allowHalfClosed
.childOption(ChannelOption.AUTO_CLOSE, false)
.childOption(ChannelOption.SO_LINGER, 0);

final SimpleChannelInboundHandler<ByteBuf> leaderHandler = new AutoCloseFalseLeader(expectedBytes,
final AutoCloseFalseLeader leaderHandler = new AutoCloseFalseLeader(expectedBytes,
serverReadExpectedLatch, doneLatch, causeRef);
final SimpleChannelInboundHandler<ByteBuf> followerHandler = new AutoCloseFalseFollower(expectedBytes,
final AutoCloseFalseFollower followerHandler = new AutoCloseFalseFollower(expectedBytes,
serverReadExpectedLatch, doneLatch, causeRef);
sb.childHandler(new ChannelInitializer<Channel>() {
@Override
Expand All @@ -398,6 +398,7 @@ protected void initChannel(Channel ch) throws Exception {

doneLatch.await();
assertNull(causeRef.get());
assertTrue(leaderHandler.seenOutputShutdown);
} finally {
if (clientChannel != null) {
clientChannel.close().sync();
Expand Down Expand Up @@ -479,7 +480,7 @@ private static final class AutoCloseFalseLeader extends SimpleChannelInboundHand
private final CountDownLatch doneLatch;
private final AtomicReference<Throwable> causeRef;
private int bytesRead;
private boolean seenOutputShutdown;
boolean seenOutputShutdown;
normanmaurer marked this conversation as resolved.
Show resolved Hide resolved

AutoCloseFalseLeader(int expectedBytes, CountDownLatch followerCloseLatch, CountDownLatch doneLatch,
AtomicReference<Throwable> causeRef) {
Expand Down Expand Up @@ -515,10 +516,6 @@ public void operationComplete(ChannelFuture future) throws Exception {
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
bytesRead += msg.readableBytes();
if (bytesRead >= expectedBytes) {
if (!seenOutputShutdown) {
causeRef.set(new IllegalStateException(
ChannelOutputShutdownEvent.class.getSimpleName() + " event was not seen"));
}
doneLatch.countDown();
}
}
Expand All @@ -527,6 +524,7 @@ protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Excep
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
if (evt instanceof ChannelOutputShutdownEvent) {
seenOutputShutdown = true;
doneLatch.countDown();
}
}

Expand Down
Expand Up @@ -23,12 +23,7 @@

import java.util.List;

public class EpollETSocketHalfClosed extends SocketHalfClosedTest {
@Override
public int maxReadCompleteWithNoDataAfterInputShutdown() {
return 1;
}

public class EpollETSocketHalfClosedTest extends SocketHalfClosedTest {
@Override
protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
return EpollSocketTestPermutation.INSTANCE.socketWithoutFastOpen();
Expand Down
Expand Up @@ -23,12 +23,7 @@

import java.util.List;

public class EpollLTSocketHalfClosed extends SocketHalfClosedTest {
@Override
public int maxReadCompleteWithNoDataAfterInputShutdown() {
return 1;
}

public class EpollLTSocketHalfClosedTest extends SocketHalfClosedTest {
@Override
protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
return EpollSocketTestPermutation.INSTANCE.socketWithoutFastOpen();
Expand Down
Expand Up @@ -23,11 +23,6 @@
import java.util.List;

public class KQueueETSocketHalfClosedTest extends SocketHalfClosedTest {
@Override
public int maxReadCompleteWithNoDataAfterInputShutdown() {
return 1;
}

@Override
protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
return KQueueSocketTestPermutation.INSTANCE.socket();
Expand Down