From 62b32fbab924a565cf3e38b02163412de35d96ea Mon Sep 17 00:00:00 2001 From: kubistika Date: Wed, 28 Aug 2019 18:25:23 +0300 Subject: [PATCH] server: proxy: only wait for server dynvc when needed --- server/proxy/pf_channels.c | 32 ++++++++++++++++++++++++++++---- server/proxy/pf_client.c | 4 ---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/server/proxy/pf_channels.c b/server/proxy/pf_channels.c index 44eb2a0..15e74fc 100644 --- a/server/proxy/pf_channels.c +++ b/server/proxy/pf_channels.c @@ -44,6 +44,13 @@ #define TAG PROXY_TAG("channels") +static void pf_channels_wait_for_server_dynvc(pServerContext* ps) +{ + WLog_DBG(TAG, "pf_channels_wait_for_server_dynvc(): waiting for server's drdynvc to be ready"); + WaitForSingleObject(ps->dynvcReady, INFINITE); + WLog_DBG(TAG, "pf_channels_wait_for_server_dynvc(): server's drdynvc is ready!"); +} + void pf_OnChannelConnectedEventHandler(void* data, ChannelConnectedEventArgs* e) { @@ -58,6 +65,8 @@ void pf_OnChannelConnectedEventHandler(void* data, } else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0) { + pf_channels_wait_for_server_dynvc(ps); + if (!ps->gfx->Open(ps->gfx)) { WLog_ERR(TAG, "failed to open GFX server"); @@ -69,13 +78,28 @@ void pf_OnChannelConnectedEventHandler(void* data, } else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0) { - if (ps->disp->Open(ps->disp) != CHANNEL_RC_OK) + UINT ret; + + ret = ps->disp->Open(ps->disp); + if (ret != CHANNEL_RC_OK) { - WLog_ERR(TAG, "failed to open disp channel"); - return; + if (ret == ERROR_NOT_FOUND) + { + /* client did not connect with disp */ + return; + } + } + else + { + pf_channels_wait_for_server_dynvc(ps); + if (ps->disp->Open(ps->disp) != CHANNEL_RC_OK) + { + WLog_ERR(TAG, "failed to open disp channel"); + return; + } } - pc->disp = (DispClientContext*) e->pInterface; + pc->disp = (DispClientContext*)e->pInterface; pf_disp_register_callbacks(pc->disp, ps->disp, pc->pdata); } else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0) diff --git a/server/proxy/pf_client.c b/server/proxy/pf_client.c index 25ddb7f..abde7f1 100644 --- a/server/proxy/pf_client.c +++ b/server/proxy/pf_client.c @@ -155,10 +155,6 @@ static BOOL pf_client_pre_connect(freerdp* instance) pf_OnChannelDisconnectedEventHandler); PubSub_SubscribeErrorInfo(instance->context->pubSub, pf_OnErrorInfo); - /* before loading client's channels, make sure proxy's dynvc is ready */ - WLog_DBG(TAG, "pf_client_pre_connect(): Waiting for proxy's server dynvc to be ready"); - WaitForSingleObject(ps->dynvcReady, INFINITE); - /** * Load all required plugins / channels / libraries specified by current * settings. -- 2.7.4