Skip to contentSkip to conversation

Remove 1 second delay before running netsh

PATCH In review Domagoj Pensa 3 participants 3 messages Dec 24, 2020 – Jan 18, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Remove 1 second delay before running netsh

When running various netsh commands before each 1 second sleep is added. As more netsh commands are run, especially for Wintun adapters, that can add to a noticable delayed connecting time.

This should be safe. No problems were found in tests and all netsh commands executed properly with delay removed. Also, no delays are used in a similar code in interactive service and netsh command executions are guarded with a semaphore.

Instead of removing management_sleep(1), management_sleep(0) is used as a replacement to allow processing any pending actions on the management interface without any wait.

---
 src/openvpn/tun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/tun.c +1 -1
index 400a50ca..0751ae46 100644
@@ -5207,7 +5207,7 @@ netsh_command(const struct argv *a, int n, int msglevel)
     for (i = 0; i < n; ++i)
     {
         bool status;
-        management_sleep(1);
+        management_sleep(0);
         netcmd_semaphore_lock();
         argv_msg_prefix(M_INFO, a, "NETSH");
         status = openvpn_execve_check(a, NULL, 0, "ERROR: netsh command failed");
Signature · 1 line
2.29.2
Acked-by on v2 1/1
#1 lore raw

Compiled with msvc.

to 24. jouluk. 2020 klo 14.00 Domagoj Pensa ([email protected]...) kirjoitti:

Quoted 42 lines

When running various netsh commands before each 1 second sleep is added. As more netsh commands are run, especially for Wintun adapters, that can add to a noticable delayed connecting time.

This should be safe. No problems were found in tests and all netsh commands executed properly with delay removed. Also, no delays are used in a similar code in interactive service and netsh command executions are guarded with a semaphore.

Instead of removing management_sleep(1), management_sleep(0) is used as a replacement to allow processing any pending actions on the management interface without any wait.

---
 src/openvpn/tun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/tun.c +1 -2
index 400a50ca..0751ae46 100644
@@ -5207,7 +5207,7 @@ netsh_command(const struct argv *a, int n, int msglevel)
     for (i = 0; i < n; ++i)
     {
         bool status;
-        management_sleep(1);
+        management_sleep(0);
         netcmd_semaphore_lock();
         argv_msg_prefix(M_INFO, a, "NETSH");
         status = openvpn_execve_check(a, NULL, 0, "ERROR: netsh command failed");
--

2.29.2

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Signature · 1 line
-Lev
#2 lore raw
In reply to Domagoj Pensa

Your patch has been applied to the master and releae/2.5 branch.

I have not tested it, not even test compiled - but if Lev says it works, this is all we need :-)

(As a side note: this reduces the *retry* delay on an error from 5 seconds to 4 seconds now - which should not make any interesting difference)

commit b1a8213ee3fe35a4617608ec7653e4dffea79207 (master) commit e7641f9b53bb6075fe7be7d5e6d16378eabebabd (release/2.5)

Author: Domagoj Pensa
Date:   Thu Dec 24 12:59:10 2020 +0100
     Remove 1 second delay before running netsh

     Signed-off-by: Domagoj Pensa <[email protected]...>
     Acked-by: Lev Stipakov <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg21405.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering