mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00: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:
parent
ccf660ce10
commit
bcddaa59a9
1 changed files with 6 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue