Re: epoll, POLLHUP, and packet loss

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

 



Davide Libenzi wrote:
We're using a very old epoll patch (ep_patch-2.4.18-0.32),
and have noticed that if there is a dropped TCP packet
followed by a FIN, epoll says the socket is ready for
POLLHUP *before* all the data has been read from the socket.
As a workaround, we are ignoring POLLHUP and simply reading
until we get EOF; this solves the problem nicely.

Hi Dan. The POLLHUP is a condition that does not preclude the socket to have data to be still read. The correct approach, with both and new epoll, is to register the event and read until data is available (if you need to). Then, if a POLLHUP has been received, do not go to wait for POLLINs.

Sounds like I need to go read Stevens again.


For what it's worth, SuSv3 says in the poll() man page:

POLLHUP
    The device has been disconnected. This event and POLLOUT are
    mutually-exclusive; a stream can never be writable if a hangup has
    occurred. However, this event and POLLIN, POLLRDNORM, POLLRDBAND,
    or POLLPRI are not mutually-exclusive.

which doesn't quite say that POLLHUP may be signalled when
there's still bunches of data to read, but it comes close.

Thanks,
Dan

--
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045

-
: 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