From 893fc6e1cf9ecc60822a0e0f10eb1ab28d7454fb Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 24 Nov 2019 10:18:08 -0600 Subject: [PATCH] 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. --- net/udp/udp_netpoll.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/net/udp/udp_netpoll.c b/net/udp/udp_netpoll.c index f648ad044e..02d6106e60 100644 --- a/net/udp/udp_netpoll.c +++ b/net/udp/udp_netpoll.c @@ -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. */