1 Star 0 Fork 43

陈亚强/spdk

forked from src-openEuler/spdk 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0009-posix-set-fd-to-1-after-close-fd-in-posix_sock_creat.patch 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
From ab69fc61073df903970dbf00582617970f97a9ea Mon Sep 17 00:00:00 2001
From: Zhiqiang Liu <[email protected]>
Date: Sun, 13 Jun 2021 21:10:19 +0800
Subject: [PATCH 26/28] posix: set fd to -1 after close(fd) in
posix_sock_create()
In posix_sock_create(), we loops through all the addresses available.
If something is wrong, we should close(fd) and set fd to -1, and
try the next address. Only, when one fd satisfies all conditions,
we will break the loop with the useful fd.
Signed-off-by: Zhiqiang Liu <[email protected]>
Change-Id: Icbfc10246c92b95cacd6eb058e6e46cf8924fc4c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8310
Reviewed-by: Changpeng Liu <[email protected]>
Reviewed-by: Aleksey Marchuk <[email protected]>
Reviewed-by: Shuhei Matsumoto <[email protected]>
Reviewed-by: Ziye Yang <[email protected]>
Tested-by: SPDK CI Jenkins <[email protected]>
Community-CI: Mellanox Build Bot
---
module/sock/posix/posix.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/module/sock/posix/posix.c b/module/sock/posix/posix.c
index c180a16..ebafc1e 100644
--- a/module/sock/posix/posix.c
+++ b/module/sock/posix/posix.c
@@ -468,12 +468,14 @@ retry:
rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val);
if (rc != 0) {
close(fd);
+ fd = -1;
/* error */
continue;
}
rc = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof val);
if (rc != 0) {
close(fd);
+ fd = -1;
/* error */
continue;
}
@@ -483,6 +485,7 @@ retry:
rc = setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &opts->priority, sizeof val);
if (rc != 0) {
close(fd);
+ fd = -1;
/* error */
continue;
}
@@ -493,6 +496,7 @@ retry:
rc = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof val);
if (rc != 0) {
close(fd);
+ fd = -1;
/* error */
continue;
}
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yaqiangchen/spdk.git
[email protected]:yaqiangchen/spdk.git
yaqiangchen
spdk
spdk
master

搜索帮助