Destroy channel listeners on terminate

This commit is contained in:
akallabeth 2020-05-12 10:54:07 +02:00
parent 5b2a4434d8
commit 2f5e5359f6
9 changed files with 77 additions and 18 deletions

View File

@ -687,7 +687,7 @@ static UINT audin_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManag
audin->listener_callback->plugin = pPlugin; audin->listener_callback->plugin = pPlugin;
audin->listener_callback->channel_mgr = pChannelMgr; audin->listener_callback->channel_mgr = pChannelMgr;
return pChannelMgr->CreateListener(pChannelMgr, "AUDIO_INPUT", 0, return pChannelMgr->CreateListener(pChannelMgr, "AUDIO_INPUT", 0,
(IWTSListenerCallback*)audin->listener_callback, NULL); &audin->listener_callback->iface, NULL);
} }
/** /**
@ -704,6 +704,13 @@ static UINT audin_plugin_terminated(IWTSPlugin* pPlugin)
return CHANNEL_RC_BAD_CHANNEL_HANDLE; return CHANNEL_RC_BAD_CHANNEL_HANDLE;
WLog_Print(audin->log, WLOG_TRACE, "..."); WLog_Print(audin->log, WLOG_TRACE, "...");
if (audin->listener_callback)
{
IWTSVirtualChannelManager* mgr = audin->listener_callback->channel_mgr;
if (mgr)
IFCALL(mgr->DestroyListener, mgr, &audin->iface);
}
audio_formats_free(audin->fixed_format, 1); audio_formats_free(audin->fixed_format, 1);
if (audin->device) if (audin->device)

View File

@ -308,8 +308,7 @@ static UINT disp_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage
disp->listener_callback->plugin = pPlugin; disp->listener_callback->plugin = pPlugin;
disp->listener_callback->channel_mgr = pChannelMgr; disp->listener_callback->channel_mgr = pChannelMgr;
status = pChannelMgr->CreateListener(pChannelMgr, DISP_DVC_CHANNEL_NAME, 0, status = pChannelMgr->CreateListener(pChannelMgr, DISP_DVC_CHANNEL_NAME, 0,
(IWTSListenerCallback*)disp->listener_callback, &disp->listener_callback->iface, &(disp->listener));
&(disp->listener));
disp->listener->pInterface = disp->iface.pInterface; disp->listener->pInterface = disp->iface.pInterface;
return status; return status;
} }
@ -322,6 +321,14 @@ static UINT disp_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage
static UINT disp_plugin_terminated(IWTSPlugin* pPlugin) static UINT disp_plugin_terminated(IWTSPlugin* pPlugin)
{ {
DISP_PLUGIN* disp = (DISP_PLUGIN*)pPlugin; DISP_PLUGIN* disp = (DISP_PLUGIN*)pPlugin;
if (disp && disp->listener_callback)
{
IWTSVirtualChannelManager* mgr = disp->listener_callback->channel_mgr;
if (mgr)
IFCALL(mgr->DestroyListener, mgr, &disp->iface);
}
free(disp->listener_callback); free(disp->listener_callback);
free(disp->iface.pInterface); free(disp->iface.pInterface);
free(pPlugin); free(pPlugin);

View File

@ -142,8 +142,8 @@ static UINT echo_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage
echo->listener_callback->plugin = pPlugin; echo->listener_callback->plugin = pPlugin;
echo->listener_callback->channel_mgr = pChannelMgr; echo->listener_callback->channel_mgr = pChannelMgr;
return pChannelMgr->CreateListener(pChannelMgr, "ECHO", 0, return pChannelMgr->CreateListener(pChannelMgr, "ECHO", 0, &echo->listener_callback->iface,
(IWTSListenerCallback*)echo->listener_callback, NULL); NULL);
} }
/** /**
@ -154,7 +154,12 @@ static UINT echo_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage
static UINT echo_plugin_terminated(IWTSPlugin* pPlugin) static UINT echo_plugin_terminated(IWTSPlugin* pPlugin)
{ {
ECHO_PLUGIN* echo = (ECHO_PLUGIN*)pPlugin; ECHO_PLUGIN* echo = (ECHO_PLUGIN*)pPlugin;
if (echo && echo->listener_callback)
{
IWTSVirtualChannelManager* mgr = echo->listener_callback->channel_mgr;
if (mgr)
IFCALL(mgr->DestroyListener, mgr, &echo->iface);
}
free(echo); free(echo);
return CHANNEL_RC_OK; return CHANNEL_RC_OK;

View File

@ -410,9 +410,9 @@ static UINT geometry_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMa
geometry->listener_callback->iface.OnNewChannelConnection = geometry_on_new_channel_connection; geometry->listener_callback->iface.OnNewChannelConnection = geometry_on_new_channel_connection;
geometry->listener_callback->plugin = pPlugin; geometry->listener_callback->plugin = pPlugin;
geometry->listener_callback->channel_mgr = pChannelMgr; geometry->listener_callback->channel_mgr = pChannelMgr;
status = pChannelMgr->CreateListener(pChannelMgr, GEOMETRY_DVC_CHANNEL_NAME, 0, status =
(IWTSListenerCallback*)geometry->listener_callback, pChannelMgr->CreateListener(pChannelMgr, GEOMETRY_DVC_CHANNEL_NAME, 0,
&(geometry->listener)); &geometry->listener_callback->iface, &(geometry->listener));
geometry->listener->pInterface = geometry->iface.pInterface; geometry->listener->pInterface = geometry->iface.pInterface;
return status; return status;
} }
@ -427,6 +427,13 @@ static UINT geometry_plugin_terminated(IWTSPlugin* pPlugin)
GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*)pPlugin; GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*)pPlugin;
GeometryClientContext* context = (GeometryClientContext*)geometry->iface.pInterface; GeometryClientContext* context = (GeometryClientContext*)geometry->iface.pInterface;
if (geometry && geometry->listener_callback)
{
IWTSVirtualChannelManager* mgr = geometry->listener_callback->channel_mgr;
if (mgr)
IFCALL(mgr->DestroyListener, mgr, &geometry->iface);
}
if (context) if (context)
HashTable_Free(context->geometries); HashTable_Free(context->geometries);

View File

@ -571,8 +571,7 @@ static UINT rdpei_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManag
rdpei->listener_callback->channel_mgr = pChannelMgr; rdpei->listener_callback->channel_mgr = pChannelMgr;
if ((error = pChannelMgr->CreateListener(pChannelMgr, RDPEI_DVC_CHANNEL_NAME, 0, if ((error = pChannelMgr->CreateListener(pChannelMgr, RDPEI_DVC_CHANNEL_NAME, 0,
(IWTSListenerCallback*)rdpei->listener_callback, &rdpei->listener_callback->iface, &(rdpei->listener))))
&(rdpei->listener))))
{ {
WLog_ERR(TAG, "ChannelMgr->CreateListener failed with error %" PRIu32 "!", error); WLog_ERR(TAG, "ChannelMgr->CreateListener failed with error %" PRIu32 "!", error);
goto error_out; goto error_out;
@ -598,6 +597,12 @@ static UINT rdpei_plugin_terminated(IWTSPlugin* pPlugin)
if (!pPlugin) if (!pPlugin)
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
if (rdpei && rdpei->listener_callback)
{
IWTSVirtualChannelManager* mgr = rdpei->listener_callback->channel_mgr;
if (mgr)
IFCALL(mgr->DestroyListener, mgr, &rdpei->iface);
}
free(rdpei->listener_callback); free(rdpei->listener_callback);
free(rdpei->context); free(rdpei->context);
free(rdpei); free(rdpei);

View File

@ -1896,8 +1896,7 @@ static UINT rdpgfx_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMana
gfx->listener_callback->plugin = pPlugin; gfx->listener_callback->plugin = pPlugin;
gfx->listener_callback->channel_mgr = pChannelMgr; gfx->listener_callback->channel_mgr = pChannelMgr;
error = pChannelMgr->CreateListener(pChannelMgr, RDPGFX_DVC_CHANNEL_NAME, 0, error = pChannelMgr->CreateListener(pChannelMgr, RDPGFX_DVC_CHANNEL_NAME, 0,
(IWTSListenerCallback*)gfx->listener_callback, &gfx->listener_callback->iface, &(gfx->listener));
&(gfx->listener));
gfx->listener->pInterface = gfx->iface.pInterface; gfx->listener->pInterface = gfx->iface.pInterface;
DEBUG_RDPGFX(gfx->log, "Initialize"); DEBUG_RDPGFX(gfx->log, "Initialize");
return error; return error;
@ -1913,6 +1912,12 @@ static UINT rdpgfx_plugin_terminated(IWTSPlugin* pPlugin)
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)pPlugin; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)pPlugin;
RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface; RdpgfxClientContext* context = (RdpgfxClientContext*)gfx->iface.pInterface;
DEBUG_RDPGFX(gfx->log, "Terminated"); DEBUG_RDPGFX(gfx->log, "Terminated");
if (gfx && gfx->listener_callback)
{
IWTSVirtualChannelManager* mgr = gfx->listener_callback->channel_mgr;
if (mgr)
IFCALL(mgr->DestroyListener, mgr, &gfx->iface);
}
rdpgfx_client_context_free(context); rdpgfx_client_context_free(context);
return CHANNEL_RC_OK; return CHANNEL_RC_OK;
} }

View File

@ -1541,8 +1541,7 @@ static UINT rdpsnd_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMana
rdpsnd->listener_callback->plugin = pPlugin; rdpsnd->listener_callback->plugin = pPlugin;
rdpsnd->listener_callback->channel_mgr = pChannelMgr; rdpsnd->listener_callback->channel_mgr = pChannelMgr;
status = pChannelMgr->CreateListener(pChannelMgr, RDPSND_DVC_CHANNEL_NAME, 0, status = pChannelMgr->CreateListener(pChannelMgr, RDPSND_DVC_CHANNEL_NAME, 0,
(IWTSListenerCallback*)rdpsnd->listener_callback, &rdpsnd->listener_callback->iface, &(rdpsnd->listener));
&(rdpsnd->listener));
rdpsnd->listener->pInterface = rdpsnd->iface.pInterface; rdpsnd->listener->pInterface = rdpsnd->iface.pInterface;
return rdpsnd_virtual_channel_event_initialized(rdpsnd); return rdpsnd_virtual_channel_event_initialized(rdpsnd);
} }
@ -1557,6 +1556,12 @@ static UINT rdpsnd_plugin_terminated(IWTSPlugin* pPlugin)
rdpsndPlugin* rdpsnd = (rdpsndPlugin*)pPlugin; rdpsndPlugin* rdpsnd = (rdpsndPlugin*)pPlugin;
if (rdpsnd) if (rdpsnd)
{ {
if (rdpsnd->listener_callback)
{
IWTSVirtualChannelManager* mgr = rdpsnd->listener_callback->channel_mgr;
if (mgr)
IFCALL(mgr->DestroyListener, mgr, &rdpsnd->iface);
}
free(rdpsnd->listener_callback); free(rdpsnd->listener_callback);
free(rdpsnd->iface.pInterface); free(rdpsnd->iface.pInterface);
} }

View File

@ -709,7 +709,12 @@ static UINT urbdrc_plugin_terminated(IWTSPlugin* pPlugin)
if (!urbdrc) if (!urbdrc)
return ERROR_INVALID_DATA; return ERROR_INVALID_DATA;
if (urbdrc->listener_callback)
{
IWTSVirtualChannelManager* mgr = urbdrc->listener_callback->channel_mgr;
if (mgr)
IFCALL(mgr->DestroyListener, mgr, &urbdrc->iface);
}
udevman = urbdrc->udevman; udevman = urbdrc->udevman;
if (udevman) if (udevman)

View File

@ -1048,7 +1048,7 @@ static UINT video_plugin_initialize(IWTSPlugin* plugin, IWTSVirtualChannelManage
callback->channel_mgr = channelMgr; callback->channel_mgr = channelMgr;
status = channelMgr->CreateListener(channelMgr, VIDEO_CONTROL_DVC_CHANNEL_NAME, 0, status = channelMgr->CreateListener(channelMgr, VIDEO_CONTROL_DVC_CHANNEL_NAME, 0,
(IWTSListenerCallback*)callback, &(video->controlListener)); &callback->iface, &(video->controlListener));
if (status != CHANNEL_RC_OK) if (status != CHANNEL_RC_OK)
return status; return status;
@ -1067,7 +1067,7 @@ static UINT video_plugin_initialize(IWTSPlugin* plugin, IWTSVirtualChannelManage
callback->channel_mgr = channelMgr; callback->channel_mgr = channelMgr;
status = channelMgr->CreateListener(channelMgr, VIDEO_DATA_DVC_CHANNEL_NAME, 0, status = channelMgr->CreateListener(channelMgr, VIDEO_DATA_DVC_CHANNEL_NAME, 0,
(IWTSListenerCallback*)callback, &(video->dataListener)); &callback->iface, &(video->dataListener));
if (status == CHANNEL_RC_OK) if (status == CHANNEL_RC_OK)
video->dataListener->pInterface = video->wtsPlugin.pInterface; video->dataListener->pInterface = video->wtsPlugin.pInterface;
@ -1084,6 +1084,19 @@ static UINT video_plugin_terminated(IWTSPlugin* pPlugin)
{ {
VIDEO_PLUGIN* video = (VIDEO_PLUGIN*)pPlugin; VIDEO_PLUGIN* video = (VIDEO_PLUGIN*)pPlugin;
if (video->control_callback)
{
IWTSVirtualChannelManager* mgr = video->control_callback->channel_mgr;
if (mgr)
IFCALL(mgr->DestroyListener, mgr, &video->control_callback->iface);
}
if (video->data_callback)
{
IWTSVirtualChannelManager* mgr = video->data_callback->channel_mgr;
if (mgr)
IFCALL(mgr->DestroyListener, mgr, &video->data_callback->iface);
}
if (video->context) if (video->context)
VideoClientContextPriv_free(video->context->priv); VideoClientContextPriv_free(video->context->priv);