From 467f7c3f6a328540994ad3acabae3e6340c6d870 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 6 Sep 2021 15:50:50 +0200 Subject: [PATCH] Fixed proxy ulimit graceful client disconnect --- channels/cliprdr/client/cliprdr_main.c | 20 ++++++++------------ channels/encomsp/client/encomsp_main.c | 14 +++----------- channels/rail/client/rail_main.c | 19 ++++++++----------- channels/rdp2tcp/client/rdp2tcp_main.c | 2 ++ channels/rdpdr/client/rdpdr_main.c | 16 +++------------- channels/rdpsnd/client/rdpsnd_main.c | 22 ++++++++++++---------- channels/remdesk/client/remdesk_main.c | 15 ++++----------- 7 files changed, 40 insertions(+), 68 deletions(-) diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c index 854b5627b..4324d380a 100644 --- a/channels/cliprdr/client/cliprdr_main.c +++ b/channels/cliprdr/client/cliprdr_main.c @@ -900,22 +900,18 @@ static VOID VCAPITYPE cliprdr_virtual_channel_open_event_ex(LPVOID lpUserParam, static UINT cliprdr_virtual_channel_event_connected(cliprdrPlugin* cliprdr, LPVOID pData, UINT32 dataLength) { - UINT32 status; - status = cliprdr->channelEntryPoints.pVirtualChannelOpenEx( - cliprdr->InitHandle, &cliprdr->OpenHandle, cliprdr->channelDef.name, - cliprdr_virtual_channel_open_event_ex); - - if (status != CHANNEL_RC_OK) - { - WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08" PRIX32 "]", - WTSErrorToString(status), status); - return status; - } + WINPR_ASSERT(cliprdr); + WINPR_ASSERT(cliprdr->context); cliprdr->MsgsHandle = channel_client_create_handler( cliprdr->context->rdpcontext, cliprdr, cliprdr_order_recv, CLIPRDR_SVC_CHANNEL_NAME); + if (!cliprdr->MsgsHandle) + return ERROR_INTERNAL_ERROR; - return CHANNEL_RC_OK; + WINPR_ASSERT(cliprdr->channelEntryPoints.pVirtualChannelOpenEx); + return cliprdr->channelEntryPoints.pVirtualChannelOpenEx( + cliprdr->InitHandle, &cliprdr->OpenHandle, cliprdr->channelDef.name, + cliprdr_virtual_channel_open_event_ex); } /** diff --git a/channels/encomsp/client/encomsp_main.c b/channels/encomsp/client/encomsp_main.c index 97f34515d..d698dcfe7 100644 --- a/channels/encomsp/client/encomsp_main.c +++ b/channels/encomsp/client/encomsp_main.c @@ -1141,16 +1141,6 @@ static UINT encomsp_virtual_channel_event_connected(encomspPlugin* encomsp, LPVO UINT32 dataLength) { UINT32 status; - status = encomsp->channelEntryPoints.pVirtualChannelOpenEx( - encomsp->InitHandle, &encomsp->OpenHandle, encomsp->channelDef.name, - encomsp_virtual_channel_open_event_ex); - - if (status != CHANNEL_RC_OK) - { - WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08" PRIX32 "]", - WTSErrorToString(status), status); - return status; - } encomsp->queue = MessageQueue_New(NULL); @@ -1168,7 +1158,9 @@ static UINT encomsp_virtual_channel_event_connected(encomspPlugin* encomsp, LPVO return ERROR_INTERNAL_ERROR; } - return CHANNEL_RC_OK; + return encomsp->channelEntryPoints.pVirtualChannelOpenEx( + encomsp->InitHandle, &encomsp->OpenHandle, encomsp->channelDef.name, + encomsp_virtual_channel_open_event_ex); } /** diff --git a/channels/rail/client/rail_main.c b/channels/rail/client/rail_main.c index cd8f934e5..d8bebe18b 100644 --- a/channels/rail/client/rail_main.c +++ b/channels/rail/client/rail_main.c @@ -570,17 +570,9 @@ static VOID VCAPITYPE rail_virtual_channel_open_event_ex(LPVOID lpUserParam, DWO static UINT rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData, UINT32 dataLength) { RailClientContext* context = rail_get_client_interface(rail); - UINT status; - status = rail->channelEntryPoints.pVirtualChannelOpenEx(rail->InitHandle, &rail->OpenHandle, - rail->channelDef.name, - rail_virtual_channel_open_event_ex); + UINT status = CHANNEL_RC_OK; - if (status != CHANNEL_RC_OK) - { - WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08" PRIX32 "]", - WTSErrorToString(status), status); - return status; - } + WINPR_ASSERT(rail); if (context) { @@ -592,8 +584,13 @@ static UINT rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData, } rail->MsgsHandle = channel_client_create_handler(rail->rdpcontext, rail, rail_order_recv, RAIL_SVC_CHANNEL_NAME); + if (!rail->MsgsHandle) + return ERROR_INTERNAL_ERROR; - return CHANNEL_RC_OK; + return rail->channelEntryPoints.pVirtualChannelOpenEx(rail->InitHandle, &rail->OpenHandle, + rail->channelDef.name, + rail_virtual_channel_open_event_ex); + ; } /** diff --git a/channels/rdp2tcp/client/rdp2tcp_main.c b/channels/rdp2tcp/client/rdp2tcp_main.c index 3fe642c81..d05b9ebe1 100644 --- a/channels/rdp2tcp/client/rdp2tcp_main.c +++ b/channels/rdp2tcp/client/rdp2tcp_main.c @@ -286,6 +286,8 @@ static VOID VCAPITYPE VirtualChannelInitEventEx(LPVOID lpUserParam, LPVOID pInit if (debug) puts("rdp2tcp connected"); + WINPR_ASSERT(plugin); + WINPR_ASSERT(plugin->channelEntryPoints.pVirtualChannelOpenEx); if (plugin->channelEntryPoints.pVirtualChannelOpenEx( pInitHandle, &plugin->openHandle, RDP2TCP_DVC_CHANNEL_NAME, VirtualChannelOpenEventEx) != CHANNEL_RC_OK) diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index af6c2a217..e0834fa7b 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -1866,23 +1866,11 @@ static UINT rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr, LPVOID pDa UINT32 dataLength) { wObject* obj; - UINT32 status; WINPR_ASSERT(rdpdr); WINPR_UNUSED(pData); WINPR_UNUSED(dataLength); - status = rdpdr->channelEntryPoints.pVirtualChannelOpenEx(rdpdr->InitHandle, &rdpdr->OpenHandle, - rdpdr->channelDef.name, - rdpdr_virtual_channel_open_event_ex); - - if (status != CHANNEL_RC_OK) - { - WLog_ERR(TAG, "pVirtualChannelOpenEx failed with %s [%08" PRIX32 "]", - WTSErrorToString(status), status); - return status; - } - rdpdr->queue = MessageQueue_New(NULL); if (!rdpdr->queue) @@ -1901,7 +1889,9 @@ static UINT rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr, LPVOID pDa return ERROR_INTERNAL_ERROR; } - return CHANNEL_RC_OK; + return rdpdr->channelEntryPoints.pVirtualChannelOpenEx(rdpdr->InitHandle, &rdpdr->OpenHandle, + rdpdr->channelDef.name, + rdpdr_virtual_channel_open_event_ex); } /** diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index ca4608c5d..28bc4bb2b 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -1189,16 +1189,7 @@ static UINT rdpsnd_virtual_channel_event_connected(rdpsndPlugin* rdpsnd, LPVOID WINPR_UNUSED(pData); WINPR_UNUSED(dataLength); - status = rdpsnd->channelEntryPoints.pVirtualChannelOpenEx( - rdpsnd->InitHandle, &rdpsnd->OpenHandle, rdpsnd->channelDef.name, - rdpsnd_virtual_channel_open_event_ex); - - if (status != CHANNEL_RC_OK) - { - WLog_ERR(TAG, "%s pVirtualChannelOpenEx failed with %s [%08" PRIX32 "]", - rdpsnd_is_dyn_str(rdpsnd->dynamic), WTSErrorToString(status), status); - return status; - } + WINPR_ASSERT(rdpsnd); rdpsnd->dsp_context = freerdp_dsp_context_new(FALSE); @@ -1210,6 +1201,17 @@ static UINT rdpsnd_virtual_channel_event_connected(rdpsndPlugin* rdpsnd, LPVOID if (!rdpsnd->pool) goto fail; + status = rdpsnd->channelEntryPoints.pVirtualChannelOpenEx( + rdpsnd->InitHandle, &rdpsnd->OpenHandle, rdpsnd->channelDef.name, + rdpsnd_virtual_channel_open_event_ex); + + if (status != CHANNEL_RC_OK) + { + WLog_ERR(TAG, "%s pVirtualChannelOpenEx failed with %s [%08" PRIX32 "]", + rdpsnd_is_dyn_str(rdpsnd->dynamic), WTSErrorToString(status), status); + goto fail; + } + return rdpsnd_process_connect(rdpsnd); fail: freerdp_dsp_context_free(rdpsnd->dsp_context); diff --git a/channels/remdesk/client/remdesk_main.c b/channels/remdesk/client/remdesk_main.c index 39f6a4ed0..a85ecdb69 100644 --- a/channels/remdesk/client/remdesk_main.c +++ b/channels/remdesk/client/remdesk_main.c @@ -867,18 +867,9 @@ static DWORD WINAPI remdesk_virtual_channel_client_thread(LPVOID arg) static UINT remdesk_virtual_channel_event_connected(remdeskPlugin* remdesk, LPVOID pData, UINT32 dataLength) { - UINT32 status; UINT error; - status = remdesk->channelEntryPoints.pVirtualChannelOpenEx( - remdesk->InitHandle, &remdesk->OpenHandle, remdesk->channelDef.name, - remdesk_virtual_channel_open_event_ex); - if (status != CHANNEL_RC_OK) - { - WLog_ERR(TAG, "pVirtualChannelOpenEx failed with %s [%08" PRIX32 "]", - WTSErrorToString(status), status); - return status; - } + WINPR_ASSERT(remdesk); remdesk->queue = MessageQueue_New(NULL); @@ -899,7 +890,9 @@ static UINT remdesk_virtual_channel_event_connected(remdeskPlugin* remdesk, LPVO goto error_out; } - return CHANNEL_RC_OK; + return remdesk->channelEntryPoints.pVirtualChannelOpenEx( + remdesk->InitHandle, &remdesk->OpenHandle, remdesk->channelDef.name, + remdesk_virtual_channel_open_event_ex); error_out: MessageQueue_Free(remdesk->queue); remdesk->queue = NULL;