summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-06-28 11:35:14 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-06-28 11:35:14 -0600
commit847af22cb8a8eae0636110b475af6b78eaf49a06 (patch)
tree934baf3382893af72fba462135373b903d9b4e77 /nuttx
parent3fff2e322e57f03d4bab2b33d49cfb02f245c654 (diff)
downloadpx4-nuttx-847af22cb8a8eae0636110b475af6b78eaf49a06.tar.gz
px4-nuttx-847af22cb8a8eae0636110b475af6b78eaf49a06.tar.bz2
px4-nuttx-847af22cb8a8eae0636110b475af6b78eaf49a06.zip
NET: Fix some errors in recent network I/O buffering when stack runs from interrupt level
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/include/nuttx/net/net.h2
-rw-r--r--nuttx/net/iob/iob_alloc.c16
-rw-r--r--nuttx/sched/os_start.c7
-rw-r--r--nuttx/sched/sem_trywait.c4
4 files changed, 16 insertions, 13 deletions
diff --git a/nuttx/include/nuttx/net/net.h b/nuttx/include/nuttx/net/net.h
index 707a499b0..fb7ff9136 100644
--- a/nuttx/include/nuttx/net/net.h
+++ b/nuttx/include/nuttx/net/net.h
@@ -156,7 +156,7 @@ int net_checksd(int fd, int oflags);
* under sched/
*/
-void weak_function net_initialize(void);
+void net_initialize(void);
void net_initlist(FAR struct socketlist *list);
void net_releaselist(FAR struct socketlist *list);
diff --git a/nuttx/net/iob/iob_alloc.c b/nuttx/net/iob/iob_alloc.c
index 179908d46..1bfbab7c4 100644
--- a/nuttx/net/iob/iob_alloc.c
+++ b/nuttx/net/iob/iob_alloc.c
@@ -107,8 +107,7 @@ static FAR struct iob_s *iob_tryalloc(bool throttled)
#if CONFIG_IOB_THROTTLE > 0
/* If there are free I/O buffers for this allocation */
- DEBUGVERIFY(sem_getvalue(sem, &semcount));
- if (semcount > 0)
+ if (sem->semcount > 0)
#endif
{
/* 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;
- 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
- //DEBUGVERIFY(sem_trywait(&g_throttle_sem));
g_throttle_sem.semcount--;
DEBUGASSERT(g_throttle_sem.semcount >= -CONFIG_IOB_THROTTLE);
#endif
diff --git a/nuttx/sched/os_start.c b/nuttx/sched/os_start.c
index a7cd4b9f4..194b42ab2 100644
--- a/nuttx/sched/os_start.c
+++ b/nuttx/sched/os_start.c
@@ -448,12 +448,7 @@ void os_start(void)
/* Initialize the network system */
#ifdef CONFIG_NET
-#if 0
- if (net_initialize != NULL)
-#endif
- {
- net_initialize();
- }
+ net_initialize();
#endif
/* The processor specific details of running the operating system
diff --git a/nuttx/sched/sem_trywait.c b/nuttx/sched/sem_trywait.c
index ce3e80b3a..38de330a5 100644
--- a/nuttx/sched/sem_trywait.c
+++ b/nuttx/sched/sem_trywait.c
@@ -116,8 +116,8 @@ int sem_trywait(FAR sem_t *sem)
saved_state = irqsave();
- /* Any further errors could only be occurred because the semaphore
- * is not available.
+ /* Any further errors could only occurr because the semaphore is not
+ * available.
*/
set_errno(EAGAIN);