Skip to content

Commit c700448

Browse files
committed
tcp: Respect SO_RCVLOWAT in tcp_poll().
Based upon a report by Vito Caputo. Signed-off-by: David S. Miller <[email protected]>
1 parent 6252352 commit c700448

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

net/ipv4/tcp.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,17 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
384384

385385
/* Connected? */
386386
if ((1 << sk->sk_state) & ~(TCPF_SYN_SENT | TCPF_SYN_RECV)) {
387+
int target = sock_rcvlowat(sk, 0, INT_MAX);
388+
389+
if (tp->urg_seq == tp->copied_seq &&
390+
!sock_flag(sk, SOCK_URGINLINE) &&
391+
tp->urg_data)
392+
target--;
393+
387394
/* Potential race condition. If read of tp below will
388395
* escape above sk->sk_state, we can be illegally awaken
389396
* in SYN_* states. */
390-
if ((tp->rcv_nxt != tp->copied_seq) &&
391-
(tp->urg_seq != tp->copied_seq ||
392-
tp->rcv_nxt != tp->copied_seq + 1 ||
393-
sock_flag(sk, SOCK_URGINLINE) || !tp->urg_data))
397+
if (tp->rcv_nxt - tp->copied_seq >= target)
394398
mask |= POLLIN | POLLRDNORM;
395399

396400
if (!(sk->sk_shutdown & SEND_SHUTDOWN)) {

0 commit comments

Comments
 (0)