net/icmp/icmp_netpoll.c and icmpv6/icmpv6_netpoll.c: ICMP/ICMPv6 should always report POLLHUP and POLLERR, regardless of requested 'events'.

This commit is contained in:
Xiang Xiao 2019-11-25 09:57:49 -06:00 committed by Gregory Nutt
parent af9c67ab58
commit 34ec7c97eb
2 changed files with 8 additions and 18 deletions

View File

@ -141,7 +141,7 @@ static uint16_t icmp_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. */
@ -217,25 +217,20 @@ int icmp_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 = icmp_poll_eventhandler;
if ((info->fds->events & POLLOUT) != 0)
if ((fds->events & POLLOUT) != 0)
{
cb->flags |= ICMP_POLL;
}
if ((info->fds->events & POLLIN) != 0)
if ((fds->events & POLLIN) != 0)
{
cb->flags |= ICMP_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.
*/

View File

@ -141,7 +141,7 @@ static uint16_t icmpv6_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. */
@ -215,25 +215,20 @@ int icmpv6_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 = icmpv6_poll_eventhandler;
if ((info->fds->events & POLLOUT) != 0)
if ((fds->events & POLLOUT) != 0)
{
cb->flags |= ICMPv6_POLL;
}
if ((info->fds->events & POLLIN) != 0)
if ((fds->events & POLLIN) != 0)
{
cb->flags |= ICMPv6_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.
*/