Added CHANNEL_EVENT_DISCONNECTED handling.
Additional error checks and logging.
This commit is contained in:
parent
9e5ed07556
commit
865bcc5d63
@ -92,7 +92,8 @@ int encomsp_virtual_channel_write(encomspPlugin* encomsp, wStream* s)
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "encomsp_virtual_channel_write: VirtualChannelWrite failed %d", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -723,7 +724,8 @@ int encomsp_send(encomspPlugin* encomsp, wStream* s)
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
WLog_ERR(TAG, "encomsp_send: VirtualChannelWrite failed %d", status);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -788,6 +790,9 @@ static VOID VCAPITYPE encomsp_virtual_channel_open_event(DWORD openHandle, UINT
|
||||
case CHANNEL_EVENT_WRITE_COMPLETE:
|
||||
Stream_Free((wStream*) pData, TRUE);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_USER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -832,7 +837,8 @@ static void encomsp_virtual_channel_event_connected(encomspPlugin* encomsp, LPVO
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "encomsp_virtual_channel_event_connected: open failed: status: %d", status);
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -842,21 +848,24 @@ static void encomsp_virtual_channel_event_connected(encomspPlugin* encomsp, LPVO
|
||||
(LPTHREAD_START_ROUTINE) encomsp_virtual_channel_client_thread, (void*) encomsp, 0, NULL);
|
||||
}
|
||||
|
||||
static void encomsp_virtual_channel_event_terminated(encomspPlugin* encomsp)
|
||||
{
|
||||
if (encomsp->queue)
|
||||
static void encomsp_virtual_channel_event_disconnected(encomspPlugin* encomsp)
|
||||
{
|
||||
UINT rc;
|
||||
MessageQueue_PostQuit(encomsp->queue, 0);
|
||||
WaitForSingleObject(encomsp->thread, INFINITE);
|
||||
|
||||
MessageQueue_Free(encomsp->queue);
|
||||
encomsp->queue = NULL;
|
||||
|
||||
CloseHandle(encomsp->thread);
|
||||
encomsp->thread = NULL;
|
||||
}
|
||||
|
||||
encomsp->channelEntryPoints.pVirtualChannelClose(encomsp->OpenHandle);
|
||||
encomsp->queue = NULL;
|
||||
encomsp->thread = NULL;
|
||||
|
||||
rc = encomsp->channelEntryPoints.pVirtualChannelClose(encomsp->OpenHandle);
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
}
|
||||
|
||||
if (encomsp->data_in)
|
||||
{
|
||||
@ -865,10 +874,12 @@ static void encomsp_virtual_channel_event_terminated(encomspPlugin* encomsp)
|
||||
}
|
||||
|
||||
encomsp_remove_open_handle_data(encomsp->OpenHandle);
|
||||
}
|
||||
|
||||
|
||||
static void encomsp_virtual_channel_event_terminated(encomspPlugin* encomsp)
|
||||
{
|
||||
encomsp_remove_init_handle_data(encomsp->InitHandle);
|
||||
|
||||
free(encomsp->context);
|
||||
|
||||
free(encomsp);
|
||||
}
|
||||
|
||||
@ -891,6 +902,7 @@ static VOID VCAPITYPE encomsp_virtual_channel_init_event(LPVOID pInitHandle, UIN
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
encomsp_virtual_channel_event_disconnected(encomsp);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_TERMINATED:
|
||||
@ -904,6 +916,7 @@ static VOID VCAPITYPE encomsp_virtual_channel_init_event(LPVOID pInitHandle, UIN
|
||||
|
||||
BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
{
|
||||
UINT rc;
|
||||
encomspPlugin* encomsp;
|
||||
EncomspClientContext* context;
|
||||
CHANNEL_ENTRY_POINTS_FREERDP* pEntryPointsEx;
|
||||
@ -945,9 +958,15 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
|
||||
CopyMemory(&(encomsp->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
|
||||
encomsp->channelEntryPoints.pVirtualChannelInit(&encomsp->InitHandle,
|
||||
rc = encomsp->channelEntryPoints.pVirtualChannelInit(&encomsp->InitHandle,
|
||||
&encomsp->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, encomsp_virtual_channel_init_event);
|
||||
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
free(encomsp);
|
||||
return -1;
|
||||
}
|
||||
encomsp->channelEntryPoints.pInterface = *(encomsp->channelEntryPoints.ppInterface);
|
||||
encomsp->channelEntryPoints.ppInterface = &(encomsp->channelEntryPoints.pInterface);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user