File: client-common-fix-retry-counter.patch

package info (click to toggle)
freerdp3 3.18.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 68,600 kB
  • sloc: ansic: 410,364; cpp: 16,855; xml: 1,721; python: 1,155; sh: 782; lisp: 408; perl: 231; cs: 191; makefile: 111
file content (74 lines) | stat: -rw-r--r-- 2,957 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
From 5223fd55cbf5af19b778ef3a7479ac61a6cee7e8 Mon Sep 17 00:00:00 2001
From: akallabeth <akallabeth@posteo.net>
Date: Thu, 13 Nov 2025 15:05:54 +0100
Subject: [client,common] fix retry counter
Forwarded: not-needed (upstream)

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;
-- 
2.47.3