libfreerdp-core: add channel reconnect

This commit is contained in:
Marc-André Moreau 2015-02-06 17:35:14 -05:00
parent b2d0aa128f
commit 3258c887a4
6 changed files with 25 additions and 15 deletions

View File

@ -1083,7 +1083,7 @@ static void drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVO
static void drdynvc_virtual_channel_event_disconnected(drdynvcPlugin* drdynvc)
{
UINT rc;
UINT status;
MessageQueue_PostQuit(drdynvc->queue, 0);
WaitForSingleObject(drdynvc->thread, INFINITE);
@ -1094,11 +1094,12 @@ static void drdynvc_virtual_channel_event_disconnected(drdynvcPlugin* drdynvc)
drdynvc->queue = NULL;
drdynvc->thread = NULL;
rc = drdynvc->channelEntryPoints.pVirtualChannelClose(drdynvc->OpenHandle);
if (CHANNEL_RC_OK != rc)
status = drdynvc->channelEntryPoints.pVirtualChannelClose(drdynvc->OpenHandle);
if (status != CHANNEL_RC_OK)
{
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
WTSErrorToString(rc), rc);
WTSErrorToString(status), status);
}
if (drdynvc->data_in)

View File

@ -22,9 +22,6 @@
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include <winpr/wlog.h>
@ -1131,8 +1128,8 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
if (!gfx->zgfx)
{
free (gfx);
free (context);
free(gfx);
free(context);
return -1;
}

View File

@ -503,17 +503,20 @@ ADDIN_ARGV* freerdp_dynamic_channel_clone(ADDIN_ARGV* channel)
ADDIN_ARGV* _channel = NULL;
_channel = (ADDIN_ARGV*) malloc(sizeof(ADDIN_ARGV));
if (!_channel)
return NULL;
_channel->argc = channel->argc;
_channel->argv = (char**) malloc(sizeof(char*) * channel->argc);
if (!_channel->argv)
goto out_free;
for (index = 0; index < _channel->argc; index++)
{
_channel->argv[index] = _strdup(channel->argv[index]);
if (!_channel->argv[index])
goto out_release_args;
}

View File

@ -202,7 +202,7 @@ int freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance)
int hostnameLength;
CHANNEL_CLIENT_DATA* pChannelClientData;
channels->is_connected = 1;
channels->connected = 1;
hostname = instance->settings->ServerHostname;
hostnameLength = (int) strlen(hostname);
@ -413,7 +413,10 @@ int freerdp_channels_disconnect(rdpChannels* channels, freerdp* instance)
CHANNEL_OPEN_DATA* pChannelOpenData;
CHANNEL_CLIENT_DATA* pChannelClientData;
channels->is_connected = 0;
if (!channels->connected)
return 0;
channels->connected = 0;
freerdp_channels_check_fds(channels, instance);
/* tell all libraries we are shutting down */
@ -498,7 +501,7 @@ UINT VCAPITYPE FreeRDP_VirtualChannelInit(LPVOID* ppInitHandle, PCHANNEL_DEF pCh
if (!pChannel)
return CHANNEL_RC_BAD_CHANNEL;
if (channels->is_connected)
if (channels->connected)
return CHANNEL_RC_ALREADY_CONNECTED;
if (versionRequested != VIRTUAL_CHANNEL_VERSION_WIN2000)
@ -571,7 +574,7 @@ UINT VCAPITYPE FreeRDP_VirtualChannelOpen(LPVOID pInitHandle, LPDWORD pOpenHandl
if (!pChannelOpenEventProc)
return CHANNEL_RC_BAD_PROC;
if (!channels->is_connected)
if (!channels->connected)
return CHANNEL_RC_NOT_CONNECTED;
pChannelOpenData = freerdp_channels_find_channel_open_data_by_name(channels, pChannelName);
@ -623,7 +626,7 @@ UINT VCAPITYPE FreeRDP_VirtualChannelWrite(DWORD openHandle, LPVOID pData, ULONG
if (!channels)
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
if (!channels->is_connected)
if (!channels->connected)
return CHANNEL_RC_NOT_CONNECTED;
if (!pData)

View File

@ -96,7 +96,7 @@ struct rdp_channels
rdpSettings* settings;
/* true once freerdp_channels_post_connect is called */
int is_connected;
BOOL connected;
/* used for locating the channels for a given instance */
freerdp* instance;

View File

@ -388,11 +388,17 @@ BOOL rdp_client_redirect(rdpRdp* rdp)
BOOL rdp_client_reconnect(rdpRdp* rdp)
{
BOOL status;
rdpContext* context = rdp->context;
rdpChannels* channels = context->channels;
freerdp_channels_disconnect(channels, context->instance);
rdp_client_disconnect(rdp);
status = rdp_client_connect(rdp);
if (status)
freerdp_channels_post_connect(channels, context->instance);
return status;
}