[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 <meijian@xiaomi.com>
This commit is contained in:
meijian 2024-02-21 20:32:06 +08:00 committed by Petro Karashchenko
parent ad7f69d25e
commit c0c9a6007c

View File

@ -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);