Message ID | 1288432420.2680.933.camel@edumazet-laptop |
---|---|
State | RFC, archived |
Delegated to: | David Miller |
Headers | show |
On Sat, 30 Oct 2010, Eric Dumazet wrote: > Le vendredi 29 octobre 2010 à 13:46 -0700, Davide Libenzi a écrit : > > > Also, why not using the existing wait->key instead of adding a poll2()? > > Indeed, if wait is not null, we have in wait->key the interest of > poller. If a particular poll() function is expensive, it can test these > bits. > > Thanks ! > > Note: I chose the 'goto skip_write' to make this patch really obvious. Plain agreement on th patch, and I understand the indent overflow concerns, but why not ... /* * No write status requested, avoid expensive OUT tests. */ if (wait && !(wait->key & (POLLWRBAND | POLLWRNORM | POLLOUT))) return mask The write-test code is the last one we do anyway. - Davide
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 3c95304..dcb84fe 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -2090,6 +2090,9 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock, return mask; } + if (wait && !(wait->key & (POLLWRBAND | POLLWRNORM | POLLOUT))) + goto skip_write; + /* writable? */ writable = unix_writable(sk); if (writable) { @@ -2111,6 +2114,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock, else set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); +skip_write: return mask; }