mirror of
https://github.com/apache/nuttx.git
synced 2026-02-07 13:32:55 +08:00
drivers/pipe: fix POLLHUP handling in poll()
For POLICY_0, when a pipe only has a reader and no writer, if the pipe is empty, set POLLHUP. For POLICY_1, when a pipe only has a reader but no writer, if the pipe is empty, POLLHUP will not be set. This change corrects poll() behavior to match the two pipe policies. No API changes. Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
This commit is contained in:
@@ -731,9 +731,13 @@ int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
eventset |= POLLIN;
|
||||
}
|
||||
|
||||
/* Notify the POLLHUP event if the pipe is empty and no writers */
|
||||
/* Notify the POLLHUP event if the pipe is empty,
|
||||
* while no writers and policy 0.
|
||||
*/
|
||||
|
||||
if (nbytes == 0 && dev->d_nwriters <= 0)
|
||||
if (nbytes == 0 &&
|
||||
dev->d_nwriters <= 0 &&
|
||||
PIPE_IS_POLICY_0(dev->d_flags))
|
||||
{
|
||||
eventset |= POLLHUP;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user