]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
pipe: fix POLLHUP handling if no events were specified
authormjg <mjg@FreeBSD.org>
Wed, 4 Nov 2020 23:11:54 +0000 (23:11 +0000)
committermjg <mjg@FreeBSD.org>
Wed, 4 Nov 2020 23:11:54 +0000 (23:11 +0000)
commita34d33fdd2a473e18962c6d4a8ba9f088985f8e7
tree61251fb728e86a2b498dfe1914fd879e2ee48161
parent7d4923469910785e75320bf8941626762ca5f6eb
pipe: fix POLLHUP handling if no events were specified

Linux allows polling without any events specified and it happens to be the case
in FreeBSD as well. POLLHUP has to be delivered regardless of the event mask
and this works fine if the condition is already present. However, if it is
missing, selrecord is only called if the eventmask has relevant bits set. This
in particular leads to a conditon where pipe_poll can return 0 events and
neglect to selrecord, while kern_poll takes it as an indication it has to go to
sleep, but then there is nobody to wake it up.

While the problem seems systemic to *_poll handlers the least we can do is fix
it up for pipes.

Reported by: Jeremie Galarneau <jeremie.galarneau at efficios.com>
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D27094
sys/kern/sys_pipe.c