Networking: Clean up and consolidate some clunky stuff by adding new net_timedwait() function

This commit is contained in:
Gregory Nutt
2015-02-09 07:50:10 -06:00
parent e218f620ac
commit 559f1ef825
8 changed files with 82 additions and 55 deletions
+4 -3
View File
@@ -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(&notify->nt_sem, &abstime);
(void)net_timedwait(&notify->nt_sem, &abstime);
ret = notify->nt_result;
/* Remove our wait structure from the list (we may no longer be at the
-11
View File
@@ -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(&notify, &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.