加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0206-fix-coredump-when-get-empty-from-udp-sendring.patch 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
From 8cd5427107511b6daed9905590c2812346a3a57d Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Thu, 27 Jun 2024 19:52:02 +0800
Subject: [PATCH] fix coredump when get empty from udp sendring
---
src/lstack/core/lstack_lwip.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index db948b0..3728100 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -255,17 +255,16 @@ struct pbuf *do_lwip_udp_get_from_sendring(struct lwip_sock *sock, uint16_t rema
struct pbuf *pbufs[count];
int actual_count = gazelle_ring_sc_dequeue(sock->send_ring, (void **)&pbufs, count);
- if (unlikely(actual_count != count)) {
+ /* it's impossible to enter this branch theoretically */
+ if (unlikely((actual_count != count) ||
+ ((actual_count != 0) && pbufs[0]->tot_len != remain_size))) {
LSTACK_LOG(ERR, LSTACK, "udp get pbuf from sendring error, expected: %d, actual: %d\n",
count, actual_count);
+ LSTACK_LOG(ERR, LSTACK, "udp get pbuf size error, expected: %d, actual: %d\n",
+ remain_size, actual_count == 0 ? 0 : pbufs[0]->tot_len);
}
- if (unlikely(pbufs[0]->tot_len != remain_size)) {
- LSTACK_LOG(ERR, LSTACK, "udp get pbuf size error, expected: %d, actual: %d\n",
- remain_size, pbufs[0]->tot_len);
- }
-
- for (int i = 0; get_protocol_stack_group()->latency_start && i < count; i++) {
+ for (int i = 0; get_protocol_stack_group()->latency_start && i < actual_count; i++) {
calculate_lstack_latency(&sock->stack->latency, pbufs[i], GAZELLE_LATENCY_WRITE_LWIP, 0);
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化