You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2024/04/22 21:03:45 UTC
(nuttx-apps) 01/03: [ping] fix ping early return when ping is interrupted by ifdown and poll return
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit c0c9a6007cc258f533586dd898c2788222f77615
Author: meijian <me...@xiaomi.com>
AuthorDate: Wed Feb 21 20:32:06 2024 +0800
[ping] fix ping early return when ping is interrupted by ifdown and poll return
During a long ping, the tester will repeatedly switch the dev interface on and off.
When the interface is down and ping is in poll sem_wait state,ifdown will trigger event of poll and post sem.
The poll will return and revent is 0x18 POLLHUP | POLLERR.Then recvfrom will process and return error to stop ping.
if ((flags & NETDEV_DOWN) != 0)
{
eventset |= (POLLHUP | POLLERR);
}
Signed-off-by: meijian <me...@xiaomi.com>
---
netutils/ping/icmp_ping.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/netutils/ping/icmp_ping.c b/netutils/ping/icmp_ping.c
index f13ca3aaf..d7e85ec35 100644
--- a/netutils/ping/icmp_ping.c
+++ b/netutils/ping/icmp_ping.c
@@ -307,6 +307,12 @@ void icmp_ping(FAR const struct ping_info_s *info)
continue;
}
+ if (priv->recvfd.revents & (POLLHUP | POLLERR))
+ {
+ icmp_callback(&result, ICMP_E_POLL, ENETDOWN);
+ continue;
+ }
+
/* Get the ICMP response (ignoring the sender) */
priv->addrlen = sizeof(struct sockaddr_in);