Bytes are dropped when using epoll and auto read = false when peer closes connection
See original GitHub issueExpected behavior
Received but not yet emitted bytes at time of peer connection close when using epoll edge triggered and autoRead=false
should be emitted (i.e. behaviour as of 4.1.6).
Actual behavior
As of 4.1.7, As soon as the remote peer disconnects, no further bytes will be emitted.
The problematic change is here: https://github.com/netty/netty/commit/631077c79391fde22afdb1e43d0f642ba530101e#diff-5d2d71235faad7440ee0020202cfa744L59
This is effectively a different take on #3709, but for the non auto read case and is a regression introduced to fix #6173.
maybeMoreDataToRead() && config.isAutoRead() || super.continueReading()
is always false
when autoRead=false
. This means that queued up bytes are not drained https://github.com/netty/netty/blob/4.1/transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollChannel.java#L378 when EPOLLRDHUP
is read, and the subsequent shutdownInput();
causes future channel.read()
calls to effectively NOOP because of https://github.com/netty/netty/blob/4.1/transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollStreamChannel.java#L972 (i.e. isInputShutdown()
is true
).
I don’t know what the right fix is, but my best naive guess would be to change the start of epollInReady()
to be:
if (!maybeMoreDataToRead && fd().isInputShutdown()) {
clearEpollIn0();
return;
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (13 by maintainers)
@alkemist - thanks for the repro … looking now.
@alkemist - Great! Thanks for the reproducer … makes life so much easier.