From 250a2be8bb9b80384381524c1fe59680119fdfa8 Mon Sep 17 00:00:00 2001 From: Martin Haimberger Date: Thu, 3 Apr 2014 06:48:41 -0700 Subject: [PATCH] Ensures that the static virtual channels are started before virtual channel data can be received --- include/freerdp/utils/svc_plugin.h | 1 + libfreerdp/utils/svc_plugin.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/freerdp/utils/svc_plugin.h b/include/freerdp/utils/svc_plugin.h index b18faa385..e4fff81be 100644 --- a/include/freerdp/utils/svc_plugin.h +++ b/include/freerdp/utils/svc_plugin.h @@ -50,6 +50,7 @@ struct rdp_svc_plugin void (*terminate_callback)(rdpSvcPlugin* plugin); HANDLE thread; + HANDLE started; wStream* data_in; void* InitHandle; DWORD OpenHandle; diff --git a/libfreerdp/utils/svc_plugin.c b/libfreerdp/utils/svc_plugin.c index b6411025f..052e8957d 100644 --- a/libfreerdp/utils/svc_plugin.c +++ b/libfreerdp/utils/svc_plugin.c @@ -177,6 +177,7 @@ static void* svc_plugin_thread_func(void* arg) IFCALL(plugin->connect_callback, plugin); + SetEvent(plugin->started); while (1) { if (!MessageQueue_Wait(plugin->MsgPipe->In)) @@ -225,6 +226,7 @@ static void svc_plugin_process_connected(rdpSvcPlugin* plugin, LPVOID pData, UIN plugin->MsgPipe = MessagePipe_New(); plugin->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) svc_plugin_thread_func, (void*) plugin, 0, NULL); + WaitForSingleObject(plugin->started,INFINITE); } static void svc_plugin_process_terminated(rdpSvcPlugin* plugin) @@ -234,6 +236,7 @@ static void svc_plugin_process_terminated(rdpSvcPlugin* plugin) MessagePipe_Free(plugin->MsgPipe); CloseHandle(plugin->thread); + CloseHandle(plugin->started); plugin->channel_entry_points.pVirtualChannelClose(plugin->OpenHandle); @@ -292,6 +295,7 @@ void svc_plugin_init(rdpSvcPlugin* plugin, CHANNEL_ENTRY_POINTS* pEntryPoints) plugin->channel_entry_points.pInterface = *(plugin->channel_entry_points.ppInterface); plugin->channel_entry_points.ppInterface = &(plugin->channel_entry_points.pInterface); + plugin->started = CreateEvent(NULL,TRUE,FALSE,NULL); svc_plugin_add_init_handle_data(plugin->InitHandle, plugin); }