Networking: Fixes another CONFIG_NET_NOINTS issues. When called sem_timedwait() with the network locked, the network stays logcked while we wait which is not what we want (without CONFIG_NET_NOINTS, interrupts are re-enabled while we wait and all is well).

This commit is contained in:
Gregory Nutt
2015-02-02 14:48:11 -06:00
parent fb72b1b1b7
commit e4c602747b
3 changed files with 18 additions and 6 deletions
+3 -3
View File
@@ -345,8 +345,8 @@ int arp_wait_cancel(FAR struct arp_notify_s *notify);
* timeout occurs. * timeout occurs.
* *
* Assumptions: * Assumptions:
* This function is called from ARP send and executes in the normal * This function is called from ARP send and mut execute with the network
* tasking environment. * un-locked.
* *
****************************************************************************/ ****************************************************************************/
@@ -366,7 +366,7 @@ int arp_wait(FAR struct arp_notify_s *notify, FAR struct timespec *timeout);
* *
* Assumptions: * Assumptions:
* This function is called from the MAC device driver indirectly through * This function is called from the MAC device driver indirectly through
* arp_arpin() and may be execute from the interrupt level. * arp_arpin() and will execute with the network locked.
* *
****************************************************************************/ ****************************************************************************/
+3 -3
View File
@@ -166,8 +166,8 @@ int arp_wait_cancel(FAR struct arp_notify_s *notify)
* timeout occurs. * timeout occurs.
* *
* Assumptions: * Assumptions:
* This function is called from ARP send and executes in the normal * This function is called from ARP send must execute with the network
* tasking environment. * un-locked (interrupts may be disabled to keep the things stable).
* *
****************************************************************************/ ****************************************************************************/
@@ -220,7 +220,7 @@ int arp_wait(FAR struct arp_notify_s *notify, FAR struct timespec *timeout)
* *
* Assumptions: * Assumptions:
* This function is called from the MAC device driver indirectly through * This function is called from the MAC device driver indirectly through
* arp_arpin() and may be execute from the interrupt level. * arp_arpin() will execute with the network locked.
* *
****************************************************************************/ ****************************************************************************/
+12
View File
@@ -190,6 +190,9 @@ int arp_send(in_addr_t ipaddr)
struct arp_notify_s notify; struct arp_notify_s notify;
struct timespec delay; struct timespec delay;
struct arp_send_s state; struct arp_send_s state;
#ifdef CONFIG_NET_NOINTS
irqstate_t flags;
#endif
net_lock_t save; net_lock_t save;
int ret; int ret;
@@ -358,12 +361,21 @@ int arp_send(in_addr_t ipaddr)
/* Now wait for response to the ARP response to be received. The /* Now wait for response to the ARP response to be received. The
* optimal delay would be the work case round trip time. * optimal delay would be the work case round trip time.
* NOTE: The network is locked.
*/ */
delay.tv_sec = CONFIG_ARP_SEND_DELAYSEC; delay.tv_sec = CONFIG_ARP_SEND_DELAYSEC;
delay.tv_nsec = CONFIG_ARP_SEND_DELAYNSEC; 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); 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 /* arp_wait will return OK if and only if the matching ARP response
* is received. Otherwise, it will return -ETIMEDOUT. * is received. Otherwise, it will return -ETIMEDOUT.