Re: [PATCH] UDP select handling of bad checksums.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux