net/udp/udp_netpoll.c: Report POLLHUP and POLLERR in 'revents' regardless the requested 'events' set. Per Opengroup.org, these bits must be ignored in the 'events' set.

This commit is contained in:
Xiang Xiao 2019-11-24 10:18:08 -06:00 committed by Gregory Nutt
parent cf9f2c56cb
commit 893fc6e1cf

View File

@ -135,7 +135,7 @@ static uint16_t udp_poll_eventhandler(FAR struct net_driver_s *dev,
if ((flags & NETDEV_DOWN) != 0)
{
eventset |= ((POLLHUP | POLLERR) & info->fds->events);
eventset |= (POLLHUP | POLLERR);
}
/* Awaken the caller of poll() is requested event occurred. */
@ -344,25 +344,20 @@ int udp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
* callback processing.
*/
cb->flags = 0;
cb->flags = NETDEV_DOWN;
cb->priv = (FAR void *)info;
cb->event = udp_poll_eventhandler;
if ((info->fds->events & POLLOUT) != 0)
if ((fds->events & POLLOUT) != 0)
{
cb->flags |= UDP_POLL;
}
if ((info->fds->events & POLLIN) != 0)
if ((fds->events & POLLIN) != 0)
{
cb->flags |= UDP_NEWDATA;
}
if ((info->fds->events & (POLLHUP | POLLERR)) != 0)
{
cb->flags |= NETDEV_DOWN;
}
/* Save the reference in the poll info structure as fds private as well
* for use during poll teardown as well.
*/