af_unix: do not report POLLOUT on listeners
authorEric Dumazet <edumazet@google.com>
Fri, 23 Oct 2015 17:59:16 +0000 (10:59 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 25 Oct 2015 13:37:45 +0000 (06:37 -0700)
poll(POLLOUT) on a listener should not report fd is ready for
a write().

This would break some applications using poll() and pfd.events = -1,
as they would not block in poll()

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Alan Burlison <Alan.Burlison@oracle.com>
Tested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/unix/af_unix.c

index 94f658235fb49a0c644a84867302cc00a75243d5..aaa0b58d6aba29816aa81c0f6ce444a0ab0be0fb 100644 (file)
@@ -326,9 +326,10 @@ found:
        return s;
 }
 
-static inline int unix_writable(struct sock *sk)
+static int unix_writable(const struct sock *sk)
 {
-       return (atomic_read(&sk->sk_wmem_alloc) << 2) <= sk->sk_sndbuf;
+       return sk->sk_state != TCP_LISTEN &&
+              (atomic_read(&sk->sk_wmem_alloc) << 2) <= sk->sk_sndbuf;
 }
 
 static void unix_write_space(struct sock *sk)