NET: Fix some errors in recent network I/O buffering when stack runs from interrupt level

This commit is contained in:
Gregory Nutt 2014-06-28 11:35:14 -06:00
parent 2fb61ad15d
commit 3b81e58047
4 changed files with 16 additions and 13 deletions

View File

@ -156,7 +156,7 @@ int net_checksd(int fd, int oflags);
* under sched/ * under sched/
*/ */
void weak_function net_initialize(void); void net_initialize(void);
void net_initlist(FAR struct socketlist *list); void net_initlist(FAR struct socketlist *list);
void net_releaselist(FAR struct socketlist *list); void net_releaselist(FAR struct socketlist *list);

View File

@ -107,8 +107,7 @@ static FAR struct iob_s *iob_tryalloc(bool throttled)
#if CONFIG_IOB_THROTTLE > 0 #if CONFIG_IOB_THROTTLE > 0
/* If there are free I/O buffers for this allocation */ /* If there are free I/O buffers for this allocation */
DEBUGVERIFY(sem_getvalue(sem, &semcount)); if (sem->semcount > 0)
if (semcount > 0)
#endif #endif
{ {
/* Take the I/O buffer from the head of the free list */ /* Take the I/O buffer from the head of the free list */
@ -122,9 +121,18 @@ static FAR struct iob_s *iob_tryalloc(bool throttled)
*/ */
g_iob_freelist = iob->io_flink; g_iob_freelist = iob->io_flink;
DEBUGVERIFY(sem_trywait(&g_iob_sem));
/* Take a semaphore count. Note that we cannot do this in
* in the orthodox way by calling sem_wait() or sem_trywait()
* because this function may be called from an interrupt
* handler. Fortunately we know at at least one free buffer
* so a simple decrement is all that is needed.
*/
g_iob_sem.semcount--;
DEBUGASSERT(g_iob_sem.semcount >= 0);
#if CONFIG_IOB_THROTTLE > 0 #if CONFIG_IOB_THROTTLE > 0
//DEBUGVERIFY(sem_trywait(&g_throttle_sem));
g_throttle_sem.semcount--; g_throttle_sem.semcount--;
DEBUGASSERT(g_throttle_sem.semcount >= -CONFIG_IOB_THROTTLE); DEBUGASSERT(g_throttle_sem.semcount >= -CONFIG_IOB_THROTTLE);
#endif #endif

View File

@ -448,12 +448,7 @@ void os_start(void)
/* Initialize the network system */ /* Initialize the network system */
#ifdef CONFIG_NET #ifdef CONFIG_NET
#if 0 net_initialize();
if (net_initialize != NULL)
#endif
{
net_initialize();
}
#endif #endif
/* The processor specific details of running the operating system /* The processor specific details of running the operating system

View File

@ -116,8 +116,8 @@ int sem_trywait(FAR sem_t *sem)
saved_state = irqsave(); saved_state = irqsave();
/* Any further errors could only be occurred because the semaphore /* Any further errors could only occurr because the semaphore is not
* is not available. * available.
*/ */
set_errno(EAGAIN); set_errno(EAGAIN);