mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Networking: Clean up and consolidate some clunky stuff by adding new net_timedwait() function
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <nuttx/net/net.h>
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "arp/arp.h"
|
||||
@@ -167,7 +168,7 @@ int arp_wait_cancel(FAR struct arp_notify_s *notify)
|
||||
*
|
||||
* Assumptions:
|
||||
* This function is called from ARP send must execute with the network
|
||||
* un-locked (interrupts may be disabled to keep the things stable).
|
||||
* locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -192,11 +193,11 @@ int arp_wait(FAR struct arp_notify_s *notify, FAR struct timespec *timeout)
|
||||
abstime.tv_nsec -= 1000000000;
|
||||
}
|
||||
|
||||
/* REVISIT: If sem_timedwait() is awakened with signal, we will return
|
||||
/* REVISIT: If net_timedwait() is awakened with signal, we will return
|
||||
* the wrong error code.
|
||||
*/
|
||||
|
||||
(void)sem_timedwait(¬ify->nt_sem, &abstime);
|
||||
(void)net_timedwait(¬ify->nt_sem, &abstime);
|
||||
ret = notify->nt_result;
|
||||
|
||||
/* Remove our wait structure from the list (we may no longer be at the
|
||||
|
||||
@@ -190,9 +190,6 @@ int arp_send(in_addr_t ipaddr)
|
||||
struct arp_notify_s notify;
|
||||
struct timespec delay;
|
||||
struct arp_send_s state;
|
||||
#ifdef CONFIG_NET_NOINTS
|
||||
irqstate_t flags;
|
||||
#endif
|
||||
net_lock_t save;
|
||||
int ret;
|
||||
|
||||
@@ -367,15 +364,7 @@ int arp_send(in_addr_t ipaddr)
|
||||
delay.tv_sec = CONFIG_ARP_SEND_DELAYSEC;
|
||||
delay.tv_nsec = CONFIG_ARP_SEND_DELAYNSEC;
|
||||
|
||||
#ifdef CONFIG_NET_NOINTS
|
||||
flags = irqsave(); /* Keep things stable */
|
||||
net_unlock(save); /* Unlock the network with interrupts disabled */
|
||||
#endif
|
||||
ret = arp_wait(¬ify, &delay);
|
||||
#ifdef CONFIG_NET_NOINTS
|
||||
save = net_lock(); /* Re-lock the network with interrupts disabled */
|
||||
irqrestore(flags);
|
||||
#endif
|
||||
|
||||
/* arp_wait will return OK if and only if the matching ARP response
|
||||
* is received. Otherwise, it will return -ETIMEDOUT.
|
||||
|
||||
Reference in New Issue
Block a user