From f617d0d3c15b07c9790dbaacfdcb79fbac74bffb Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 10 Jul 2018 13:26:25 +0200 Subject: [PATCH] Moved automatic reconnect after timeout to freerdp_connect. --- client/X11/xf_client.c | 6 --- libfreerdp/core/freerdp.c | 114 +++++++++++++++++++++++----------------------- 2 files changed, 57 insertions(+), 63 deletions(-) diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 84c431c..fba5b4a 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -1487,12 +1487,6 @@ static DWORD WINAPI xf_client_thread(LPVOID param) if (!status) { - if (freerdp_get_last_error(instance->context) == FREERDP_ERROR_CONNECT_TRANSPORT_FAILED) - status = freerdp_reconnect(instance); - } - - if (!status) - { if (freerdp_get_last_error(instance->context) == FREERDP_ERROR_AUTHENTICATION_FAILED) exit_code = XF_EXIT_AUTH_FAILURE; diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 72cae89..41a47c8 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -197,82 +197,82 @@ BOOL freerdp_connect(freerdp* instance) goto freerdp_connect_finally; } - if (!status) - goto freerdp_connect_finally; - - if (status) + if (instance->settings->DumpRemoteFx) { - UINT status2; + instance->update->pcap_rfx = pcap_open(instance->settings->DumpRemoteFxFile, + TRUE); - if (instance->settings->DumpRemoteFx) - { - instance->update->pcap_rfx = pcap_open(instance->settings->DumpRemoteFxFile, - TRUE); - - if (instance->update->pcap_rfx) - instance->update->dump_rfx = TRUE; - } + if (instance->update->pcap_rfx) + instance->update->dump_rfx = TRUE; + } + if (status) + { IFCALLRET(instance->PostConnect, status, instance); instance->ConnectionCallbackState = CLIENT_STATE_POSTCONNECT_PASSED; if (status) status2 = freerdp_channels_post_connect(instance->context->channels, instance); + } + else + { + if (freerdp_get_last_error(instance->context) == FREERDP_ERROR_CONNECT_TRANSPORT_FAILED) + status = freerdp_reconnect(instance); + } - if (!status || (status2 != CHANNEL_RC_OK) - || !update_post_connect(instance->update)) - { - WLog_ERR(TAG, "freerdp_post_connect failed"); - - if (!freerdp_get_last_error(rdp->context)) - freerdp_set_last_error(instance->context, FREERDP_ERROR_POST_CONNECT_FAILED); + if (!status || (status2 != CHANNEL_RC_OK) + || !update_post_connect(instance->update)) + { + WLog_ERR(TAG, "freerdp_post_connect failed"); - status = FALSE; - goto freerdp_connect_finally; - } + if (!freerdp_get_last_error(rdp->context)) + freerdp_set_last_error(instance->context, FREERDP_ERROR_POST_CONNECT_FAILED); - if (instance->settings->PlayRemoteFx) - { - wStream* s; - rdpUpdate* update; - pcap_record record; - update = instance->update; - update->pcap_rfx = pcap_open(settings->PlayRemoteFxFile, FALSE); - status = FALSE; - - if (!update->pcap_rfx) - goto freerdp_connect_finally; - else - update->play_rfx = TRUE; + status = FALSE; + goto freerdp_connect_finally; + } - status = TRUE; + if (instance->settings->PlayRemoteFx) + { + wStream* s; + rdpUpdate* update; + pcap_record record; + update = instance->update; + update->pcap_rfx = pcap_open(settings->PlayRemoteFxFile, FALSE); + status = FALSE; + + if (!update->pcap_rfx) + goto freerdp_connect_finally; + else + update->play_rfx = TRUE; - while (pcap_has_next_record(update->pcap_rfx) && status) - { - pcap_get_next_record_header(update->pcap_rfx, &record); + status = TRUE; - if (!(s = StreamPool_Take(rdp->transport->ReceivePool, record.length))) - break; + while (pcap_has_next_record(update->pcap_rfx) && status) + { + pcap_get_next_record_header(update->pcap_rfx, &record); - record.data = Stream_Buffer(s); - pcap_get_next_record_content(update->pcap_rfx, &record); - Stream_SetLength(s, record.length); - Stream_SetPosition(s, 0); + if (!(s = StreamPool_Take(rdp->transport->ReceivePool, record.length))) + break; - if (!update->BeginPaint(update->context)) - status = FALSE; - else if (update_recv_surfcmds(update, s) < 0) - status = FALSE; - else if (!update->EndPaint(update->context)) - status = FALSE; + record.data = Stream_Buffer(s); + pcap_get_next_record_content(update->pcap_rfx, &record); + Stream_SetLength(s, record.length); + Stream_SetPosition(s, 0); - Stream_Release(s); - } + if (!update->BeginPaint(update->context)) + status = FALSE; + else if (update_recv_surfcmds(update, s) < 0) + status = FALSE; + else if (!update->EndPaint(update->context)) + status = FALSE; - pcap_close(update->pcap_rfx); - update->pcap_rfx = NULL; - goto freerdp_connect_finally; + Stream_Release(s); } + + pcap_close(update->pcap_rfx); + update->pcap_rfx = NULL; + goto freerdp_connect_finally; } if (rdp->errorInfo == ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES) -- 2.7.4