diff options
author | David S. Miller <davem@davemloft.net> | 2008-10-06 10:43:54 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-10-06 10:43:54 -0700 |
commit | c7004482e8dcb7c3c72666395cfa98a216a4fb70 (patch) | |
tree | fe771839cf85fc5b455d53025eb97f20779e2eda /net/ipv4/tcp.c | |
parent | 6252352d16f7b45a0fd42224f7e70e0288dc4480 (diff) | |
download | kernel-crypto-c7004482e8dcb7c3c72666395cfa98a216a4fb70.tar.gz kernel-crypto-c7004482e8dcb7c3c72666395cfa98a216a4fb70.tar.xz kernel-crypto-c7004482e8dcb7c3c72666395cfa98a216a4fb70.zip |
tcp: Respect SO_RCVLOWAT in tcp_poll().
Based upon a report by Vito Caputo.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r-- | net/ipv4/tcp.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 1ab341e5d3e..7d81a1ee550 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -384,13 +384,17 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait) /* Connected? */ if ((1 << sk->sk_state) & ~(TCPF_SYN_SENT | TCPF_SYN_RECV)) { + int target = sock_rcvlowat(sk, 0, INT_MAX); + + if (tp->urg_seq == tp->copied_seq && + !sock_flag(sk, SOCK_URGINLINE) && + tp->urg_data) + target--; + /* Potential race condition. If read of tp below will * escape above sk->sk_state, we can be illegally awaken * in SYN_* states. */ - if ((tp->rcv_nxt != tp->copied_seq) && - (tp->urg_seq != tp->copied_seq || - tp->rcv_nxt != tp->copied_seq + 1 || - sock_flag(sk, SOCK_URGINLINE) || !tp->urg_data)) + if (tp->rcv_nxt - tp->copied_seq >= target) mask |= POLLIN | POLLRDNORM; if (!(sk->sk_shutdown & SEND_SHUTDOWN)) { |