Attention is currently required from: Arne Schwabe, Gert Doering, Heiko Hund, 
Răzvan Cojocaru.

Hello Arne Schwabe, Gert Doering, Heiko Hund,

I'd like you to reexamine a change. Please visit

    https://gerrit.openvpn.net/c/openvpn/+/2356?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Code-Review+2 by Heiko Hund

The change is no longer submittable: Code-Review and checks~ChecksSubmitRule 
are unsatisfied now.


Change subject: openvpnserv: report pipe creation errors where they happen
......................................................................

openvpnserv: report pipe creation errors where they happen

Log failures to create or disconnect the first pipe instance with
their own messages, instead of falling through to the generic one.
This makes a pipe name already in use distinguishable, and logs
the error before CloseHandleEx() can clobber it.

Change-Id: Id795de7dfe1324fb00660b6f8a9043732aa3e84c
Signed-off-by: Razvan Cojocaru <[email protected]>
---
M src/openvpnserv/interactive.c
1 file changed, 18 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/56/2356/2

diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c
index 240aeaf..05d0de8 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -4079,36 +4079,39 @@
     swprintf(pipe_name, _countof(pipe_name), L"\\\\.\\pipe\\" _L(PACKAGE) 
L"%ls\\service",
              service_instance);

+    HANDLE pipe = INVALID_HANDLE_VALUE;
+    DWORD error = ERROR_SUCCESS;
+
     static HANDLE blocker = INVALID_HANDLE_VALUE;
     if (blocker == INVALID_HANDLE_VALUE)
     {
         blocker = CreateNamedPipe(pipe_name, flags | 
FILE_FLAG_FIRST_PIPE_INSTANCE, mode,
                                   PIPE_UNLIMITED_INSTANCES, 1024, 1024, 0, 
&sa);
-        if (blocker != INVALID_HANDLE_VALUE && !DisconnectNamedPipe(blocker))
+        if (blocker == INVALID_HANDLE_VALUE)
         {
-            DWORD error = GetLastError();
+            error = MsgToEventLog(M_SYSERR, L"Could not create first instance 
of named pipe");
+            goto out;
+        }
+        if (!DisconnectNamedPipe(blocker))
+        {
+            error = MsgToEventLog(M_SYSERR, L"Could not disconnect first 
instance of named pipe");
             CloseHandleEx(&blocker);
-            SetLastError(error);
+            goto out;
         }
     }

-    /* Without the first instance, fail and try again with the next call */
-    HANDLE pipe = INVALID_HANDLE_VALUE;
-    if (blocker != INVALID_HANDLE_VALUE)
-    {
-        pipe = CreateNamedPipe(pipe_name, flags, mode, 
PIPE_UNLIMITED_INSTANCES, 1024, 1024, 0,
-                               &sa);
-    }
-
+    pipe = CreateNamedPipe(pipe_name, flags, mode, PIPE_UNLIMITED_INSTANCES, 
1024, 1024, 0, &sa);
     if (pipe == INVALID_HANDLE_VALUE)
     {
-        DWORD error = MsgToEventLog(M_SYSERR, L"Could not create named pipe");
-        LocalFree(sd);
-        SetLastError(error);
-        return INVALID_HANDLE_VALUE;
+        error = MsgToEventLog(M_SYSERR, L"Could not create named pipe");
     }

+out:
     LocalFree(sd);
+    if (pipe == INVALID_HANDLE_VALUE)
+    {
+        SetLastError(error);
+    }
     return pipe;
 }


--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2356?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id795de7dfe1324fb00660b6f8a9043732aa3e84c
Gerrit-Change-Number: 2356
Gerrit-PatchSet: 2
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Gert Doering <[email protected]>
Gerrit-Reviewer: Heiko Hund <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Heiko Hund <[email protected]>
Gerrit-Attention: Răzvan Cojocaru <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
Gerrit-Attention: Gert Doering <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to