From 5223fd55cbf5af19b778ef3a7479ac61a6cee7e8 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 13 Nov 2025 15:05:54 +0100 Subject: [PATCH] [client,common] fix retry counter The counter must start at 0 and be incremented afer use --- client/SDL/SDL2/dialogs/sdl_dialogs.cpp | 2 +- client/SDL/SDL3/dialogs/sdl_dialogs.cpp | 2 +- client/common/client.c | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/SDL/SDL2/dialogs/sdl_dialogs.cpp b/client/SDL/SDL2/dialogs/sdl_dialogs.cpp index aa65abfa1..c12ca7753 100644 --- a/client/SDL/SDL2/dialogs/sdl_dialogs.cpp +++ b/client/SDL/SDL2/dialogs/sdl_dialogs.cpp @@ -253,7 +253,7 @@ SSIZE_T sdl_retry_dialog(freerdp* instance, const char* what, size_t current, sdl->connection_dialog->showInfo("[%s] retry %" PRIuz "/%" PRIuz ", delaying %" PRIuz "ms before next attempt", - what, current, max, delay); + what, current + 1, max, delay); return WINPR_ASSERTING_INT_CAST(SSIZE_T, delay); } diff --git a/client/SDL/SDL3/dialogs/sdl_dialogs.cpp b/client/SDL/SDL3/dialogs/sdl_dialogs.cpp index 1525567a1..bbbbcd5c2 100644 --- a/client/SDL/SDL3/dialogs/sdl_dialogs.cpp +++ b/client/SDL/SDL3/dialogs/sdl_dialogs.cpp @@ -246,7 +246,7 @@ SSIZE_T sdl_retry_dialog(freerdp* instance, const char* what, size_t current, sdl->dialog.showInfo("[%s] retry %" PRIuz "/%" PRIuz ", delaying %" PRIuz "ms before next attempt", - what, current, max, delay); + what, current + 1, max, delay); return WINPR_ASSERTING_INT_CAST(ssize_t, delay); } diff --git a/client/common/client.c b/client/common/client.c index 5bcf8f8e5..06912abc9 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -1299,7 +1299,7 @@ SSIZE_T client_common_retry_dialog(freerdp* instance, const char* what, size_t c } WLog_INFO(TAG, "[%s] retry %" PRIuz "/%" PRIuz ", delaying %" PRIuz "ms before next attempt", - what, current, max, delay); + what, current + 1, max, delay); return WINPR_ASSERTING_INT_CAST(SSIZE_T, delay); } @@ -1364,7 +1364,7 @@ BOOL client_auto_reconnect_ex(freerdp* instance, BOOL (*window_events)(freerdp* while (retry) { /* Quit retrying if max retries has been exceeded */ - if ((maxRetries > 0) && (numRetries++ >= maxRetries)) + if ((maxRetries > 0) && (numRetries >= maxRetries)) { WLog_DBG(TAG, "AutoReconnect retries exceeded."); return FALSE; @@ -1375,6 +1375,9 @@ BOOL client_auto_reconnect_ex(freerdp* instance, BOOL (*window_events)(freerdp* const SSIZE_T delay = IFCALLRESULT(5000, instance->RetryDialog, instance, "connection", numRetries, NULL); + if (delay < 0) + return FALSE; + numRetries++; if (freerdp_reconnect(instance)) return TRUE;