From: Geliang Tang <tanggeliang@kylinos.cn>
cfg_input is opened twice regardless of whether cfg_sockopt_types.mptfo
is configured. This can be simplified to open it once at the beginning
of main_loop() and close it at the end, because no need to repeatedly
open and close cfg_input during cfg_repeat.
Co-developed-by: Cong Liu <liucong2@kylinos.cn>
Signed-off-by: Cong Liu <liucong2@kylinos.cn>
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/net/mptcp/mptcp_connect.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index 893dc36b12f6..5301062a5f3b 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -1268,7 +1268,7 @@ int main_loop(void)
struct addrinfo *peer;
struct wstate winfo;
- if (cfg_input && cfg_sockopt_types.mptfo) {
+ if (cfg_input) {
fd_in = open(cfg_input, O_RDONLY);
if (fd_in < 0)
xerror("can't open %s:%d", cfg_input, errno);
@@ -1291,12 +1291,6 @@ int main_loop(void)
if (cfg_cmsg_types.cmsg_enabled)
apply_cmsg_types(fd, &cfg_cmsg_types);
- if (cfg_input && !cfg_sockopt_types.mptfo) {
- fd_in = open(cfg_input, O_RDONLY);
- if (fd_in < 0)
- xerror("can't open %s:%d", cfg_input, errno);
- }
-
ret = copyfd_io(fd_in, fd, 1, 0, &winfo);
if (ret)
return ret;
@@ -1312,14 +1306,14 @@ int main_loop(void)
set_nonblock(fd, false);
if (connect(fd, peer->ai_addr, peer->ai_addrlen))
xerror("can't reconnect: %d", errno);
- if (cfg_input)
- close(fd_in);
memset(&winfo, 0, sizeof(winfo));
goto again;
} else {
close(fd);
}
+ if (cfg_input)
+ close(fd_in);
return 0;
}
--
2.43.0