This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 5b1f2dff5ff6f63be1c8442decbb85bd087fd401 Author: YAMAMOTO Takashi <[email protected]> AuthorDate: Mon Jul 19 19:45:30 2021 +0900 iob_tryalloc: Fix throttled allocation If threads are blocking for throttled allocation, g_throttle_sem.semcount doesn't represent the number of usable IOBs well. Note: For non-throttled allocations, the g_iob_committed mechanism is a rescue. But there is no equivalent for throttled allocations. --- mm/iob/iob_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/iob/iob_alloc.c b/mm/iob/iob_alloc.c index d4c9e91..c26269f 100644 --- a/mm/iob/iob_alloc.c +++ b/mm/iob/iob_alloc.c @@ -237,7 +237,8 @@ FAR struct iob_s *iob_tryalloc(bool throttled, enum iob_user_e consumerid) #if CONFIG_IOB_THROTTLE > 0 /* If there are free I/O buffers for this allocation */ - if (sem->semcount > 0) + if (sem->semcount > 0 || + (throttled && g_iob_sem.semcount - CONFIG_IOB_THROTTLE > 0)) #endif { /* Take the I/O buffer from the head of the free list */
