Merge pull request #3800 from mfleisz/channel_fixes

Cleanup channel structs in channels_close to allow instance reuse
This commit is contained in:
Norbert Federa 2017-02-24 13:25:52 +01:00 committed by GitHub
commit 689d2696d2
2 changed files with 44 additions and 30 deletions

View File

@ -628,6 +628,13 @@ BOOL freerdp_client_add_static_channel(rdpSettings* settings, int count,
{
int index;
ADDIN_ARGV* args;
if (!settings || !params || !params[0])
return FALSE;
if (freerdp_static_channel_collection_find(settings, params[0]))
return TRUE;
args = (ADDIN_ARGV*) calloc(1, sizeof(ADDIN_ARGV));
if (!args)
@ -673,6 +680,13 @@ BOOL freerdp_client_add_dynamic_channel(rdpSettings* settings, int count,
{
int index;
ADDIN_ARGV* args;
if (!settings || !params || !params[0])
return FALSE;
if (freerdp_dynamic_channel_collection_find(settings, params[0]))
return TRUE;
args = (ADDIN_ARGV*) malloc(sizeof(ADDIN_ARGV));
if (!args)
@ -2686,7 +2700,7 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
if (settings->DeviceRedirection)
{
if (!freerdp_client_load_static_channel_addin(channels, settings, "rdpdr",
settings))
settings))
return FALSE;
if (!freerdp_static_channel_collection_find(settings, "rdpsnd"))
@ -2738,14 +2752,11 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
if (settings->RedirectClipboard)
{
if (!freerdp_static_channel_collection_find(settings, "cliprdr"))
{
char* params[1];
params[0] = "cliprdr";
char* params[1];
params[0] = "cliprdr";
if (!freerdp_client_add_static_channel(settings, 1, (char**) params))
return FALSE;
}
if (!freerdp_client_add_static_channel(settings, 1, (char**) params))
return FALSE;
}
if (settings->LyncRdpMode)
@ -2764,14 +2775,14 @@ BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
if (settings->EncomspVirtualChannel)
{
if (!freerdp_client_load_static_channel_addin(channels, settings, "encomsp",
settings))
settings))
return FALSE;
}
if (settings->RemdeskVirtualChannel)
{
if (!freerdp_client_load_static_channel_addin(channels, settings, "remdesk",
settings))
settings))
return FALSE;
}

View File

@ -106,9 +106,6 @@ error:
void freerdp_channels_free(rdpChannels* channels)
{
int index;
CHANNEL_OPEN_DATA* pChannelOpenData;
if (!channels)
return;
@ -120,23 +117,6 @@ void freerdp_channels_free(rdpChannels* channels)
channels->queue = NULL;
}
for (index = 0; index < channels->clientDataCount; index++)
{
pChannelOpenData = &channels->openDataList[index];
if (pChannelOpenData->pInterface)
{
free(pChannelOpenData->pInterface);
pChannelOpenData->pInterface = NULL;
}
freerdp_channel_remove_open_handle_data(&g_ChannelHandles, pChannelOpenData->OpenHandle);
if (channels->openHandles)
HashTable_Remove(channels->openHandles,
(void*)(UINT_PTR)pChannelOpenData->OpenHandle);
}
if (channels->openHandles)
HashTable_Free(channels->openHandles);
@ -655,6 +635,7 @@ UINT freerdp_channels_disconnect(rdpChannels* channels, freerdp* instance)
void freerdp_channels_close(rdpChannels* channels, freerdp* instance)
{
int index;
CHANNEL_OPEN_DATA* pChannelOpenData;
CHANNEL_CLIENT_DATA* pChannelClientData;
freerdp_channels_check_fds(channels, instance);
@ -675,7 +656,29 @@ void freerdp_channels_close(rdpChannels* channels, freerdp* instance)
}
}
channels->clientDataCount = 0;
MessageQueue_PostQuit(channels->queue, 0);
for (index = 0; index < channels->openDataCount; index++)
{
pChannelOpenData = &channels->openDataList[index];
if (pChannelOpenData->pInterface)
{
free(pChannelOpenData->pInterface);
pChannelOpenData->pInterface = NULL;
}
freerdp_channel_remove_open_handle_data(&g_ChannelHandles, pChannelOpenData->OpenHandle);
if (channels->openHandles)
HashTable_Remove(channels->openHandles,
(void*)(UINT_PTR)pChannelOpenData->OpenHandle);
}
channels->openDataCount = 0;
channels->initDataCount = 0;
instance->settings->ChannelCount = 0;
}
static UINT VCAPITYPE FreeRDP_VirtualChannelInitEx(LPVOID lpUserParam, LPVOID clientContext,