[Openvpn-devel,S] Change in openvpn[master]: dco-win: simplity do_close_link_socket()

Message ID b17dc911cc88b91809d6d903954210f133d831a6-HTML@gerrit.openvpn.net
State New
Headers show
Series [Openvpn-devel,S] Change in openvpn[master]: dco-win: simplity do_close_link_socket() | expand

Commit Message

flichtenheld (Code Review) Nov. 21, 2024, 6:07 p.m. UTC
Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/813?usp=email

to review the following change.


Change subject: dco-win: simplity do_close_link_socket()
......................................................................

dco-win: simplity 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 <lev@openvpn.net>
---
M src/openvpn/init.c
1 file changed, 8 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/813/1

Patch

diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index 9371024..656fedf 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -3940,16 +3940,16 @@ 
 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_socket)
-    {
-        c->c2.link_socket->sd = SOCKET_UNDEFINED;
-    }
-
     if (c->c2.link_socket && c->c2.link_socket_owned)
     {
+        /* 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_socket->sd = SOCKET_UNDEFINED;
+        }
+
         link_socket_close(c->c2.link_socket);
         c->c2.link_socket = NULL;
     }