diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-06-28 13:32:42 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-06-28 13:32:42 -0600 |
commit | e817f162e832cc01ab8eba4ce583a139d9c01ee9 (patch) | |
tree | 97652bf1bb89f45719023c7e12d4da71bae8fe79 /nuttx/net/iob | |
parent | f92be2ee4139bc633b5006395186c42d18111f5e (diff) | |
download | px4-nuttx-e817f162e832cc01ab8eba4ce583a139d9c01ee9.tar.gz px4-nuttx-e817f162e832cc01ab8eba4ce583a139d9c01ee9.tar.bz2 px4-nuttx-e817f162e832cc01ab8eba4ce583a139d9c01ee9.zip |
Fix another place where sem_tryalloc may be called from the interrupt level. Thanks Manuel
Diffstat (limited to 'nuttx/net/iob')
-rw-r--r-- | nuttx/net/iob/iob_alloc_qentry.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/nuttx/net/iob/iob_alloc_qentry.c b/nuttx/net/iob/iob_alloc_qentry.c index 8f425adb0..23bd8712e 100644 --- a/nuttx/net/iob/iob_alloc_qentry.c +++ b/nuttx/net/iob/iob_alloc_qentry.c @@ -105,7 +105,16 @@ static FAR struct iob_qentry_s *iob_tryalloc_qentry(void) */ g_iob_freeqlist = iobq->qe_flink; - DEBUGVERIFY(sem_trywait(&g_qentry_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_qentry_sem.semcount--; + DEBUGASSERT(g_qentry_sem.semcount >= 0); /* Put the I/O buffer in a known state */ |