From 250bde034d6e62741b4dfc6e7c5c4c610761ab56 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Wed, 27 Nov 2019 08:04:14 -0600 Subject: [PATCH] net/: icmp[v6]_pollsetup should always return POLLWRNORM if the caller requests it since ICMP[v6] doesn't utilize IOB buffer for sending and always needs to wait for an ICMP[v6]_POLL. --- net/icmp/icmp_netpoll.c | 18 ++++++------------ net/icmpv6/icmpv6_netpoll.c | 18 ++++++------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/net/icmp/icmp_netpoll.c b/net/icmp/icmp_netpoll.c index f168d8e441..29941aaa1c 100644 --- a/net/icmp/icmp_netpoll.c +++ b/net/icmp/icmp_netpoll.c @@ -137,13 +137,6 @@ static uint16_t icmp_poll_eventhandler(FAR struct net_driver_s *dev, eventset |= (POLLHUP | POLLERR); } - /* ICMP_POLL is a sign that we are free to send data. */ - - else if ((flags & DEVPOLL_MASK) == ICMP_POLL) - { - eventset |= (POLLOUT & info->fds->events); - } - /* Awaken the caller of poll() is requested event occurred. */ if (eventset) @@ -221,11 +214,6 @@ int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) cb->priv = (FAR void *)info; cb->event = icmp_poll_eventhandler; - if ((fds->events & POLLOUT) != 0) - { - cb->flags |= ICMP_POLL; - } - if ((fds->events & POLLIN) != 0) { cb->flags |= ICMP_NEWDATA; @@ -246,6 +234,12 @@ int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) fds->revents |= (POLLRDNORM & fds->events); } + /* Always report POLLWRNORM if caller request it because we don't utilize + * IOB buffer for sending. + */ + + fds->revents |= (POLLWRNORM & fds->events); + /* Check if any requested events are already in effect */ if (fds->revents != 0) diff --git a/net/icmpv6/icmpv6_netpoll.c b/net/icmpv6/icmpv6_netpoll.c index 433f743add..5d96f89f44 100644 --- a/net/icmpv6/icmpv6_netpoll.c +++ b/net/icmpv6/icmpv6_netpoll.c @@ -137,13 +137,6 @@ static uint16_t icmpv6_poll_eventhandler(FAR struct net_driver_s *dev, eventset |= (POLLHUP | POLLERR); } - /* ICMP_POLL is a sign that we are free to send data. */ - - else if ((flags & DEVPOLL_MASK) == ICMPv6_POLL) - { - eventset |= (POLLOUT & info->fds->events); - } - /* Awaken the caller of poll() is requested event occurred. */ if (eventset) @@ -219,11 +212,6 @@ int icmpv6_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) cb->priv = (FAR void *)info; cb->event = icmpv6_poll_eventhandler; - if ((fds->events & POLLOUT) != 0) - { - cb->flags |= ICMPv6_POLL; - } - if ((fds->events & POLLIN) != 0) { cb->flags |= ICMPv6_NEWDATA; @@ -244,6 +232,12 @@ int icmpv6_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) fds->revents |= (POLLRDNORM & fds->events); } + /* Always report POLLWRNORM if caller request it because we don't utilize + * IOB buffer for sending. + */ + + fds->revents |= (POLLWRNORM & fds->events); + /* Check if any requested events are already in effect */ if (fds->revents != 0)