Merge pull request #5901 from nfedera/add_connstate_active_timeout

core: fix endless loops waiting for activation
This commit is contained in:
Martin Fleisz 2020-02-21 09:05:47 +01:00 committed by GitHub
commit 2d38a8a110
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 8 deletions

View File

@ -24,6 +24,8 @@
#include "activation.h"
#include "display.h"
#define TAG FREERDP_TAG("core.activation")
/*
static const char* const CTRLACTION_STRINGS[] =
{
@ -255,6 +257,7 @@ BOOL rdp_send_server_font_map_pdu(rdpRdp* rdp)
BOOL rdp_recv_deactivate_all(rdpRdp* rdp, wStream* s)
{
UINT16 lengthSourceDescriptor;
UINT32 timeout;
if (rdp->state == CONNECTION_STATE_ACTIVE)
rdp->deactivation_reactivation = TRUE;
@ -288,18 +291,22 @@ BOOL rdp_recv_deactivate_all(rdpRdp* rdp, wStream* s)
rdp_client_transition_to_state(rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE);
while (rdp->state != CONNECTION_STATE_ACTIVE)
for (timeout = 0; timeout < rdp->settings->TcpAckTimeout; timeout += 100)
{
if (rdp_check_fds(rdp) < 0)
return FALSE;
if (freerdp_shall_disconnect(rdp->instance))
break;
return TRUE;
SwitchToThread();
if (rdp->state == CONNECTION_STATE_ACTIVE)
return TRUE;
Sleep(100);
}
return TRUE;
WLog_ERR(TAG, "Timeout waiting for activation");
return FALSE;
}
BOOL rdp_send_deactivate_all(rdpRdp* rdp)

View File

@ -233,6 +233,7 @@ BOOL rdp_client_connect(rdpRdp* rdp)
/* make sure SSL is initialize for earlier enough for crypto, by taking advantage of winpr SSL
* FIPS flag for openssl initialization */
DWORD flags = WINPR_SSL_INIT_DEFAULT;
UINT32 timeout;
if (!rdp_client_reset_codecs(rdp->context))
return FALSE;
@ -361,18 +362,22 @@ BOOL rdp_client_connect(rdpRdp* rdp)
return FALSE;
}
while (rdp->state != CONNECTION_STATE_ACTIVE)
for (timeout = 0; timeout < settings->TcpAckTimeout; timeout += 100)
{
if (rdp_check_fds(rdp) < 0)
{
freerdp_set_last_error_if_not(rdp->context, FREERDP_ERROR_CONNECT_TRANSPORT_FAILED);
return FALSE;
}
SwitchToThread();
if (rdp->state == CONNECTION_STATE_ACTIVE)
return TRUE;
Sleep(100);
}
return TRUE;
WLog_ERR(TAG, "Timeout waiting for activation");
return FALSE;
}
BOOL rdp_client_disconnect(rdpRdp* rdp)