Stephen Hemminger wrote:
> This patch addresses the issue of blocking usage of select() by UDP
> applications.
I'm glad to see someone actually putting some code forward in this debate...
Looks pretty good, but can't you implement this a bit cleaner by just
wrapping datagram_poll? Something like:
unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait)
{
unsigned int mask = datagram_poll(file, sock, wait);
if ((mask & POLLRDNORM) != 0 && (file->f_flags & O_NONBLOCK) == 0 &&
(sk->sk_shutdown & RCV_SHUTDOWN) == 0) {
struct sk_buff_head *rcvq = &sk->sk_receive_queue;
struct sk_buff *skb;
spin_lock_irq(&rcvq->lock);
// the skb_peek() loop from your udp_rcv_ready() goes here...
spin_unlock_irq(&rcvq->lock);
if (skb == NULL) /* nope, nothing really ready */
mask &= ~(POLLIN | POLLRDNORM);
}
return mask;
}
That way you duplicate a lot less code. It does slightly more work but
only in the broken !O_NONBLOCK case - the fast path is just as quick.
-Mitch
|