]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
tcp: Respect SO_RCVLOWAT in tcp_poll().
authorDavid S. Miller <davem@davemloft.net>
Mon, 6 Oct 2008 17:43:54 +0000 (10:43 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Oct 2008 17:43:54 +0000 (10:43 -0700)
Based upon a report by Vito Caputo.

Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp.c

index 1ab341e5d3e0f70383fdfa460b0ee9071b282df7..7d81a1ee5507c08a2fb2b297fb387a7cf6bc55bb 100644 (file)
@@ -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)) {