diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 8c9c01460..4a92692f5 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 @@ -1362,19 +1360,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 */ @@ -1392,6 +1391,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; @@ -1405,7 +1405,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()). @@ -1453,11 +1452,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; @@ -1602,9 +1596,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 29d964f59..a894a94f8 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 5db64acdb..5b9f99227 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));