UDP Networking: Misc fixes to get the last changes working + cleanup

This commit is contained in:
Gregory Nutt
2015-05-29 14:32:56 -06:00
parent fa8b7c19b7
commit 0bdf2d5360
6 changed files with 29 additions and 68 deletions
+17 -5
View File
@@ -42,6 +42,7 @@
#include <time.h>
#include <semaphore.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <netinet/in.h>
@@ -67,7 +68,7 @@
/* List of tasks waiting for ARP events */
static struct arp_notify_s *g_arp_waiters;
static FAR struct arp_notify_s *g_arp_waiters;
/****************************************************************************
* Private Functions
@@ -176,6 +177,7 @@ int arp_wait(FAR struct arp_notify_s *notify, FAR struct timespec *timeout)
{
struct timespec abstime;
irqstate_t flags;
int errcode;
int ret;
/* And wait for the ARP response (or a timeout). Interrupts will be re-
@@ -193,11 +195,21 @@ int arp_wait(FAR struct arp_notify_s *notify, FAR struct timespec *timeout)
abstime.tv_nsec -= 1000000000;
}
/* REVISIT: If net_timedwait() is awakened with signal, we will return
* the wrong error code.
*/
/* Wait to get either the correct response or a timeout. */
do
{
/* The only errors that we expect would be if the abstime timeout
* expires or if the wait were interrupted by a signal.
*/
ret = net_timedwait(&notify->nt_sem, &abstime);
errcode = ((ret < 0) ? errno : 0);
}
while (ret < 0 && errcode == EINTR);
/* Then get the real result of the transfer */
(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
+4 -2
View File
@@ -293,7 +293,7 @@ int arp_send(in_addr_t ipaddr)
state.snd_cb = arp_callback_alloc(dev);
if (!state.snd_cb)
{
ndbg("ERROR: Failed to allocate a cllback\n");
ndbg("ERROR: Failed to allocate a callback\n");
ret = -ENOMEM;
goto errout_with_lock;
}
@@ -373,6 +373,7 @@ int arp_send(in_addr_t ipaddr)
{
/* Break out on a send failure */
ndbg("ERROR: Send failed: %d\n", ret);
break;
}
@@ -390,7 +391,7 @@ int arp_send(in_addr_t ipaddr)
* is received. Otherwise, it will return -ETIMEDOUT.
*/
if (ret == OK)
if (ret >= OK)
{
/* Break out if arp_wait() fails */
@@ -400,6 +401,7 @@ int arp_send(in_addr_t ipaddr)
/* Increment the retry count */
state.snd_retries++;
ndbg("ERROR: arp_wait failed: %d\n", ret);
}
sem_destroy(&state.snd_sem);