10 Star 1 Fork 11

src-openEuler/lldpad

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
huawei-set-send-timeout-to-10s.patch 970 Bytes
一键复制 编辑 原始数据 按行查看 历史
yc555 提交于 2024-10-10 13:13 +08:00 . lldpad: sync bugfix patches
From c680a1d75af2e9b104ea92669872d74e9e8127b6 Mon Sep 17 00:00:00 2001
From: yangchen <yangchen145@huawei.com>
Date: Thu, 10 Oct 2024 12:32:41 +0800
Subject: [PATCH] set send timeout to 10s
set send timeout to 10s,avoid getting stuck in the send() function for a
long time when there is no space in send buffer
---
lldp/l2_packet_linux.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lldp/l2_packet_linux.c b/lldp/l2_packet_linux.c
index be9b8af..4ce5e76 100644
--- a/lldp/l2_packet_linux.c
+++ b/lldp/l2_packet_linux.c
@@ -220,6 +220,12 @@ struct l2_packet_data * l2_packet_init(
ifname, MAC2STR(l2->curr_mac_addr),
MAC2STR(l2->perm_mac_addr), MAC2STR(l2->san_mac_addr));
+ struct timeval timeout;
+ timeout.tv_sec = 10;
+ timeout.tv_usec = 0;
+ socklen_t len = sizeof(timeout);
+ setsockopt(l2->fd, SOL_SOCKET, SO_SNDTIMEO, &timeout, len);
+
struct packet_mreq mr;
memset(&mr, 0, sizeof(mr));
mr.mr_ifindex = l2->ifindex;
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/lldpad.git
git@gitee.com:src-openeuler/lldpad.git
src-openeuler
lldpad
lldpad
master

搜索帮助