This is an automated email from the ASF dual-hosted git repository.

linguini pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 678164bf4e0 net_bufpool.c:when timeout value is zero,It don't break 
netlock
678164bf4e0 is described below

commit 678164bf4e05a87dc1618717a9184bad87b6a0f5
Author: wangchen <[email protected]>
AuthorDate: Mon May 26 12:55:24 2025 +0800

    net_bufpool.c:when timeout value is zero,It don't break netlock
    
    Resolve some timing issues caused by calling net_breaklock to release 
netlock in the function NET_BUFPOOL_TRYALLOC
    
    Signed-off-by: wangchen <[email protected]>
---
 net/utils/net_bufpool.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/net/utils/net_bufpool.c b/net/utils/net_bufpool.c
index 70f0fba2094..89f4f9d3515 100644
--- a/net/utils/net_bufpool.c
+++ b/net/utils/net_bufpool.c
@@ -107,7 +107,15 @@ FAR void *net_bufpool_timedalloc(FAR struct net_bufpool_s 
*pool,
       DEBUGASSERT(pool->nodesize > 0);
     }
 
-  ret = net_sem_timedwait_uninterruptible(&pool->sem, timeout);
+  if (timeout == 0)
+    {
+      ret = nxsem_trywait(&pool->sem);
+    }
+  else
+    {
+      ret = net_sem_timedwait_uninterruptible(&pool->sem, timeout);
+    }
+
   if (ret != OK)
     {
       return NULL;

Reply via email to