From 7c5e036ee9c5a58896371ab640097cc4e47a0c63 Mon Sep 17 00:00:00 2001 From: Jim Mott Date: Fri, 4 Jan 2008 12:32:48 -0800 Subject: [PATCH] SDP - Bug829: poll() always returns POLLOUT on non-blocking socket Signed-off-by: Jim Mott --- drivers/infiniband/ulp/sdp/sdp_main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/sdp/sdp_main.c b/drivers/infiniband/ulp/sdp/sdp_main.c index 686ce5a28f88..2263faf77271 100644 --- a/drivers/infiniband/ulp/sdp/sdp_main.c +++ b/drivers/infiniband/ulp/sdp/sdp_main.c @@ -2032,17 +2032,27 @@ static inline unsigned int sdp_listen_poll(const struct sock *sk) 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; } -- 2.50.1