[ofa-general] [PATCH 1/1] SDP - Bug829: poll() always returns POLLOUT on non-blocking socket

Jim Mott jim at mellanox.com
Fri Jan 4 12:59:46 PST 2008


Signed-off-by: Jim Mott <jim at mellanox.com>
---

Index: ofa_1_3_dev_kernel/drivers/infiniband/ulp/sdp/sdp_main.c
===================================================================
--- ofa_1_3_dev_kernel.orig/drivers/infiniband/ulp/sdp/sdp_main.c
2008-01-04 14:11:55.000000000 -0600
+++ ofa_1_3_dev_kernel/drivers/infiniband/ulp/sdp/sdp_main.c
2008-01-04 14:12:02.000000000 -0600
@@ -2013,17 +2013,27 @@ static inline unsigned int sdp_listen_po
 static unsigned int sdp_poll(struct file *file, struct socket *socket,
                             struct poll_table_struct *wait)
 {
-       int mask;
+       unsigned int     mask;
+       struct sock     *sk  = socket->sk;
+       struct sdp_sock *ssk = sdp_sk(sk);
+
        sdp_dbg_data(socket->sk, "%s\n", __func__);

        mask = datagram_poll(file, socket, wait);
+
+       /*
+        * Adjust for memory in later kernels
+        */
+       if (!sk_stream_memory_free(sk) || !slots_free(ssk))
+               mask &= ~(POLLOUT | POLLWRNORM | POLLWRBAND);
+
        /* TODO: Slightly ugly: it would be nicer if there was function
         * like datagram_poll that didn't include poll_wait,
         * then we could reverse the order. */
-       if (socket->sk->sk_state == TCP_LISTEN)
-               return sdp_listen_poll(socket->sk);
+       if (sk->sk_state == TCP_LISTEN)
+               return sdp_listen_poll(sk);

-       if (sdp_sk(socket->sk)->urg_data & TCP_URG_VALID)
+       if (ssk->urg_data & TCP_URG_VALID)
                mask |= POLLPRI;
        return mask;
 }



More information about the general mailing list