Follow up fix for #4631

Remember the callback state to avoid calling reerdp_channels_post_connect
before the corresponding client callback has benn called.
This might happen during redirection and reconnection.
This commit is contained in:
Armin Novak 2018-06-18 10:44:35 +02:00
parent a716dc244c
commit 273655a850
5 changed files with 10 additions and 12 deletions

View File

@ -32,9 +32,6 @@
#include <freerdp/client/geometry.h>
#include <freerdp/client/video.h>
int xf_on_channel_connected(freerdp* instance, const char* name, void* pInterface);
int xf_on_channel_disconnected(freerdp* instance, const char* name, void* pInterface);
void xf_OnChannelConnectedEventHandler(void* context, ChannelConnectedEventArgs* e);
void xf_OnChannelDisconnectedEventHandler(void* context, ChannelDisconnectedEventArgs* e);

View File

@ -240,7 +240,9 @@ struct rdp_freerdp
Callback for context deallocation
Can be set before calling freerdp_context_free() to have it executed before deallocation.
Must be set to NULL if not needed. */
UINT64 paddingC[48 - 35]; /* 35 */
UINT64 paddingC[47 - 35]; /* 35 */
ALIGN64 ConnectionCallbackState; /* 48 */
ALIGN64 pPreConnect PreConnect; /**< (offset 48)
Callback for pre-connect operations.

View File

@ -347,11 +347,11 @@ UINT freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance)
UINT error = CHANNEL_RC_OK;
UINT index;
char* hostname;
int hostnameLength;
size_t hostnameLength;
CHANNEL_CLIENT_DATA* pChannelClientData;
channels->connected = TRUE;
hostname = instance->settings->ServerHostname;
hostnameLength = (int) strlen(hostname);
hostnameLength = strlen(hostname);
for (index = 0; index < channels->clientDataCount; index++)
{

View File

@ -357,7 +357,6 @@ BOOL rdp_client_redirect(rdpRdp* rdp)
rdpSettings* settings;
rdpContext* context;
rdpChannels* channels;
BOOL connected;
if (!rdp || !rdp->context || !rdp->context->channels)
return FALSE;
@ -365,7 +364,6 @@ BOOL rdp_client_redirect(rdpRdp* rdp)
settings = rdp->settings;
context = rdp->context;
channels = context->channels;
connected = channels->connected;
if (!rdp_client_disconnect_and_clear(rdp))
return FALSE;
@ -426,7 +424,7 @@ BOOL rdp_client_redirect(rdpRdp* rdp)
status = rdp_client_connect(rdp);
if (status && connected)
if (status && (context->instance->ConnectionCallbackState == 2))
status = (freerdp_channels_post_connect(context->channels, context->instance) == CHANNEL_RC_OK);
return status;
@ -437,21 +435,19 @@ BOOL rdp_client_reconnect(rdpRdp* rdp)
BOOL status;
rdpContext* context;
rdpChannels* channels;
BOOL connected;
if (!rdp || !rdp->context || !rdp->context->channels)
return FALSE;
context = rdp->context;
channels = context->channels;
connected = channels->connected;
if (!rdp_client_disconnect_and_clear(rdp))
return FALSE;
status = rdp_client_connect(rdp);
if (status && connected)
if (status && (context->instance->ConnectionCallbackState == 2))
status = (freerdp_channels_post_connect(channels, context->instance) == CHANNEL_RC_OK);
return status;

View File

@ -165,6 +165,7 @@ BOOL freerdp_connect(freerdp* instance)
settings = instance->settings;
instance->context->codecs = codecs_new(instance->context);
IFCALLRET(instance->PreConnect, status, instance);
instance->ConnectionCallbackState++;
if (status)
status2 = freerdp_channels_pre_connect(instance->context->channels,
@ -212,6 +213,7 @@ BOOL freerdp_connect(freerdp* instance)
}
IFCALLRET(instance->PostConnect, status, instance);
instance->ConnectionCallbackState++;
if (status)
status2 = freerdp_channels_post_connect(instance->context->channels, instance);
@ -501,6 +503,7 @@ BOOL freerdp_disconnect(freerdp* instance)
}
IFCALL(instance->PostDisconnect, instance);
instance->ConnectionCallbackState++;
if (instance->update->pcap_rfx)
{