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

Native epoll transport should honor AUTO_READ flag #6173

Closed
wazhar opened this issue Jan 4, 2017 · 3 comments
Closed

Native epoll transport should honor AUTO_READ flag #6173

wazhar opened this issue Jan 4, 2017 · 3 comments
Assignees
Labels

Comments

@wazhar
Copy link

wazhar commented Jan 4, 2017

Expected behavior

Data should only be read when requested, if AUTO_READ option is set to false

Actual behavior

When using Epoll transport, netty calls handler's channelRead0 without requesting read, even if AUTO_READ option is set to false. NIO Transport on the other hand works as expected.
This could be a problem if you are acting as a proxy.

Steps to reproduce

This is reproducible using small sized data I could reproduce it starting from 1 byte till 150k. Client must close connection as soon as done writing. Here are some settings I used.

  1. SO_RCVBUF option was not set, although setting it didn't help.
  2. AUTO_READ false
  3. TCP_NODELAY false
  4. SO_REUSEADDR true
  5. cat /proc/sys/net/ipv4/tcp_rmem
    4096 87380 6291456
  6. /proc/sys/net/ipv4/tcp_wmem
    4096 16384 4194304

This could help generating test data quickly:
cp some_large_file 10k_file
truncate -s 10240 10k_file
nc host port < 10k_file

Netty version

4.1.6.Final

JVM version

java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

OS version

Linux 4.8.15-300.fc25.x86_64
x86_64 x86_64 x86_64 GNU/Linux

@blueswhisper
Copy link

may be you should use Epoll level trigger, default Epoll Mode is edge trigger, see this

@wazhar
Copy link
Author

wazhar commented Jan 5, 2017

Setting LEVEL_TRIGGERED for bootstrap option EPOLL_MODE did not help.

@Scottmitch
Copy link
Member

Client must close connection as soon as done writing.

IIRC if we get a EPOLLRDHUP then we must read until we get a socket error for stream sockets [1] while in ET mode as we may not be notified of activity on that FD again. This may not be necessary in LT mode, and especially if NIO transport is still able to deliver all data. I will need to investigate more.

[1] https://github.com/netty/netty/blob/4.1/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollRecvByteAllocatorHandle.java#L57

@Scottmitch Scottmitch self-assigned this Jan 7, 2017
Scottmitch added a commit to Scottmitch/netty that referenced this issue Jan 10, 2017
Motivation:
EpollRecvByteAllocatorHandle will read unconditionally if EPOLLRDHUP has been received. However we can just treat this the same was we do as data maybe pending in ET mode, and let LT mode notify us if we haven't read all data.

Modifications:
- EpollRecvByteAllocatorHandle should not always force a read just because EPOLLRDHUP has been received, but just treated as an indicator that there maybe more data to read in ET mode

Result:
Fixes netty#6173.
liuzhengyang pushed a commit to liuzhengyang/netty that referenced this issue Sep 10, 2017
Motivation:
EpollRecvByteAllocatorHandle will read unconditionally if EPOLLRDHUP has been received. However we can just treat this the same was we do as data maybe pending in ET mode, and let LT mode notify us if we haven't read all data.

Modifications:
- EpollRecvByteAllocatorHandle should not always force a read just because EPOLLRDHUP has been received, but just treated as an indicator that there maybe more data to read in ET mode

Result:
Fixes netty#6173.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants