From 468f53ae3bfcfca6563acbf648e7a0bc6f94b038 Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Wed, 27 Jul 2022 23:45:08 -0400 Subject: [PATCH] Allow a few levels of recursion in virtual_output_callback() Without this, replies to commands from the management client are sometimes lost if the server is writing when a command comes in and leads to a recursive call to this function. For some reason I've not been able to trigger this on Linux, but it does sometimes happen on Windows during intense write activity by openvpn.exe sending log lines to the management client. Signed-off-by: Selva Nair Acked-by: Gert Doering Message-Id: <20220728034508.15180-2-selva.nair@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24751.html Signed-off-by: Gert Doering (cherry picked from commit 4dfd592ff1ee18aa4859264c8a341dfa1a291988) --- src/openvpn/manage.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 0ba4f677d..6af551528 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -314,8 +314,7 @@ virtual_output_callback_func(void *arg, const unsigned int flags, const char *st #define AF_DID_PUSH (1<<0) #define AF_DID_RESET (1<<1) - - if (!recursive_level) /* don't allow recursion */ + if (recursive_level < 5) /* limit recursion */ { struct gc_arena gc = gc_new(); struct log_entry e; @@ -382,6 +381,12 @@ virtual_output_callback_func(void *arg, const unsigned int flags, const char *st --recursive_level; } + else + { + /* cannot use msg here */ + printf("virtual_output: message to management interface " + "dropped due to recursion: <%s>\n", str); + } } /* -- 2.47.2