Correctly guard against NotYetConnectedExceptions when handling RDHUP.

Motivation:

Commit 2c1f17faa268b9a1b8ef8f1ddaf832d1397719a3 introduced a regression which could cause NotYetConnectedExceptions when handling RDHUP events.

Modifications:

Correct ignore NotYetConnectedException when handling RDHUP events.

Result:

No more regression.
This commit is contained in:
Norman Maurer 2016-08-29 12:43:11 +02:00
parent 53d4950704
commit dcbef5ee6f

View File

@ -33,6 +33,7 @@ import io.netty.util.ReferenceCountUtil;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.NotYetConnectedException;
import java.nio.channels.UnresolvedAddressException;
import static io.netty.util.internal.ObjectUtil.checkNotNull;
@ -348,19 +349,29 @@ abstract class AbstractEpollChannel extends AbstractChannel implements UnixChann
try {
fd().shutdown(true, false);
clearEpollIn0();
pipeline().fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
} catch (IOException ignored) {
// We attempted to shutdown and failed, which means the input has already effectively been
// shutdown.
pipeline().fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
close(voidPromise());
fireEventAndClose(ChannelInputShutdownEvent.INSTANCE);
return;
} catch (NotYetConnectedException ignore) {
// We attempted to shutdown and failed, which means the input has already effectively been
// shutdown.
fireEventAndClose(ChannelInputShutdownEvent.INSTANCE);
return;
}
pipeline().fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
} else {
close(voidPromise());
}
}
}
private void fireEventAndClose(Object evt) {
pipeline().fireUserEventTriggered(evt);
close(voidPromise());
}
@Override
protected void flush0() {
// Flush immediately only when there's no pending flush.