提交 c7004482 编写于 作者: D David S. Miller

tcp: Respect SO_RCVLOWAT in tcp_poll().

Based upon a report by Vito Caputo.
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 6252352d
...@@ -384,13 +384,17 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait) ...@@ -384,13 +384,17 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
/* Connected? */ /* Connected? */
if ((1 << sk->sk_state) & ~(TCPF_SYN_SENT | TCPF_SYN_RECV)) { 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 /* Potential race condition. If read of tp below will
* escape above sk->sk_state, we can be illegally awaken * escape above sk->sk_state, we can be illegally awaken
* in SYN_* states. */ * in SYN_* states. */
if ((tp->rcv_nxt != tp->copied_seq) && if (tp->rcv_nxt - tp->copied_seq >= target)
(tp->urg_seq != tp->copied_seq ||
tp->rcv_nxt != tp->copied_seq + 1 ||
sock_flag(sk, SOCK_URGINLINE) || !tp->urg_data))
mask |= POLLIN | POLLRDNORM; mask |= POLLIN | POLLRDNORM;
if (!(sk->sk_shutdown & SEND_SHUTDOWN)) { if (!(sk->sk_shutdown & SEND_SHUTDOWN)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册