From: Lev Stipakov Date: Tue, 31 Dec 2024 14:54:17 +0000 (+0100) Subject: dco-win: simplify do_close_link_socket() X-Git-Tag: v2.7_alpha1~128 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1452625bc364cb5847daedaad238c7a5eb3eff5e;p=thirdparty%2Fopenvpn.git dco-win: simplify do_close_link_socket() c->c2.link_socket_owned is true in client mode and for the global context in the server mode - those are exactly the cases when we want to set sd to undefined when using dco-win. Change-Id: I3232dd8d855ca3f198b4ca3b2ef4f67cec49f3d4 Signed-off-by: Lev Stipakov Acked-by: Gert Doering Message-Id: <20241231145417.12128-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30328.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 850cd126..2bd55189 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -4018,21 +4018,18 @@ do_close_free_key_schedule(struct context *c, bool free_ssl_ctx) static void do_close_link_socket(struct context *c) { - /* in dco-win case, link socket is a tun handle which is - * closed in do_close_tun(). Set it to UNDEFINED so - * we won't use WinSock API to close it. */ - if (tuntap_is_dco_win(c->c1.tuntap) && c->c2.link_sockets) - { - for (int i = 0; i < c->c1.link_sockets_num; i++) - { - c->c2.link_sockets[i]->sd = SOCKET_UNDEFINED; - } - } - if (c->c2.link_sockets && c->c2.link_socket_owned) { for (int i = 0; i < c->c1.link_sockets_num; i++) { + /* in dco-win case, link socket is a tun handle which is + * closed in do_close_tun(). Set it to UNDEFINED so + * we won't use WinSock API to close it. */ + if (tuntap_is_dco_win(c->c1.tuntap)) + { + c->c2.link_sockets[i]->sd = SOCKET_UNDEFINED; + } + link_socket_close(c->c2.link_sockets[i]); } c->c2.link_sockets = NULL;