From c22490ec3b2050571dff5fae55247ec476ed6788 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 27 Feb 2014 16:55:07 -0500 Subject: [PATCH] xfreerdp: disable auto-reconnect by default, add command-line option --- client/X11/xf_client.c | 22 ++++++++-------------- client/common/cmdline.c | 5 +++++ libfreerdp/core/settings.c | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 331cae1..a47b0e6 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -51,8 +51,6 @@ #include #endif -#define WITH_AUTORECONNECT - #include #include #include @@ -1367,19 +1365,20 @@ void* xf_channels_thread(void* arg) return NULL; } -#ifdef WITH_AUTORECONNECT BOOL xf_auto_reconnect(freerdp* instance) { - xfContext* xfc = (xfContext*)instance->context; + xfContext* xfc = (xfContext*) instance->context; UINT32 num_retries = 0; UINT32 max_retries = instance->settings->AutoReconnectMaxRetries; /* Only auto reconnect on network disconnects. */ - if (freerdp_error_info(instance) != 0) return FALSE; + if (freerdp_error_info(instance) != 0) + return FALSE; /* A network disconnect was detected */ fprintf(stderr, "Network disconnect!\n"); + if (!instance->settings->AutoReconnectionEnabled) { /* No auto-reconnect - just quit */ @@ -1397,6 +1396,7 @@ BOOL xf_auto_reconnect(freerdp* instance) /* Attempt the next reconnect */ fprintf(stderr, "Attempting reconnect (%u of %u)\n", num_retries, max_retries); + if (freerdp_reconnect(instance)) { xfc->disconnect = FALSE; @@ -1410,7 +1410,6 @@ BOOL xf_auto_reconnect(freerdp* instance) return FALSE; } -#endif /** Main loop for the rdp connection. * It will be run from the thread's entry point (thread_func()). @@ -1458,11 +1457,6 @@ void* xf_thread(void* param) ZeroMemory(wfds, sizeof(wfds)); ZeroMemory(&timeout, sizeof(struct timeval)); -#ifdef WITH_AUTORECONNECT - instance->settings->AutoReconnectionEnabled = TRUE; - instance->settings->AutoReconnectMaxRetries = 20; -#endif - status = freerdp_connect(instance); xfc = (xfContext*) instance->context; @@ -1607,9 +1601,9 @@ void* xf_thread(void* param) { if (freerdp_check_fds(instance) != TRUE) { -#ifdef WITH_AUTORECONNECT - if (xf_auto_reconnect(instance)) continue; -#endif + if (xf_auto_reconnect(instance)) + continue; + fprintf(stderr, "Failed to check FreeRDP file descriptor\n"); break; } diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 29d964f..a894a94 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -148,6 +148,7 @@ COMMAND_LINE_ARGUMENT_A args[] = { "help", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, NULL, NULL, NULL, -1, "?", "print help" }, { "play-rfx", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Replay rfx pcap file" }, { "auth-only", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Authenticate only." }, + { "auto-reconnect", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Automatic reconnection" }, { "reconnect-cookie", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Pass base64 reconnect cookie to the connection" }, { "print-reconnect-cookie", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Print base64 reconnect cookie after connecting" }, { "heartbeat", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Support heartbeat PDUs" }, @@ -1716,6 +1717,10 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, { settings->AuthenticationOnly = arg->Value ? TRUE : FALSE; } + CommandLineSwitchCase(arg, "auto-reconnect") + { + settings->AutoReconnectionEnabled = arg->Value ? TRUE : FALSE; + } CommandLineSwitchCase(arg, "reconnect-cookie") { BYTE *base64; diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index 5db64ac..5b9f992 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -387,7 +387,7 @@ rdpSettings* freerdp_settings_new(DWORD flags) settings->FrameAcknowledge = 2; settings->MouseMotion = TRUE; - settings->AutoReconnectionEnabled = TRUE; + settings->AutoReconnectionEnabled = FALSE; settings->AutoReconnectMaxRetries = 20; settings->ClientAutoReconnectCookie = (ARC_CS_PRIVATE_PACKET*) malloc(sizeof(ARC_CS_PRIVATE_PACKET)); -- 2.7.4