gazelle/0320-Protocal-fixing-deathlock-between-protocol-threads-a.patch
yinbin 71fa5d085f sync update gazelle max numa nodes 8
(cherry picked from commit 26d5d01d849a92f24bac7fc68b38890f0193908e)
2025-03-04 21:11:25 +08:00

34 lines
1.0 KiB
Diff

From 3619605574d0c624513a10ecd543cc2bc1608f7b Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Fri, 24 Jan 2025 14:18:26 +0800
Subject: [PATCH] Protocal: fixing deathlock between protocol threads and app
thread
---
src/lstack/core/lstack_lwip.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 648da58..3bb943f 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -267,7 +267,14 @@ struct pbuf *do_lwip_alloc_pbuf(pbuf_layer layer, uint16_t length, pbuf_type typ
static inline bool pbuf_allow_append(struct pbuf *pbuf, uint16_t remain_size)
{
- pthread_spin_lock(&pbuf->pbuf_lock);
+ int ret;
+
+ /* Using pthread_spin_trylock to avoid deadlock between app thread and lstack threads */
+ ret = pthread_spin_trylock(&pbuf->pbuf_lock);
+ if (ret != 0) {
+ return false;
+ }
+
if (pbuf->tot_len > remain_size) {
pthread_spin_unlock(&pbuf->pbuf_lock);
return false;
--
2.33.0