Unified client stop

This commit is contained in:
akallabeth
2022-01-19 12:11:48 +01:00
committed by akallabeth
parent 7641710f60
commit cdbfff87ea
6 changed files with 28 additions and 42 deletions

View File

@@ -67,14 +67,7 @@ static int mfreerdp_client_stop(rdpContext *context)
{
mfContext *mfc = (mfContext *)context;
freerdp_abort_connect(context->instance);
if (mfc->common.thread)
{
SetEvent(mfc->stopEvent);
WaitForSingleObject(mfc->common.thread, INFINITE);
CloseHandle(mfc->common.thread);
mfc->common.thread = NULL;
}
freerdp_client_common_stop(context);
if (mfc->view_ownership)
{

View File

@@ -668,12 +668,6 @@ static int wfl_client_start(rdpContext* context)
return 0;
}
static int wfl_client_stop(rdpContext* context)
{
WINPR_UNUSED(context);
return 0;
}
static int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
{
ZeroMemory(pEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS));
@@ -685,7 +679,7 @@ static int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
pEntryPoints->ClientNew = wlf_client_new;
pEntryPoints->ClientFree = wlf_client_free;
pEntryPoints->ClientStart = wfl_client_start;
pEntryPoints->ClientStop = wfl_client_stop;
pEntryPoints->ClientStop = freerdp_client_common_stop;
return 0;
}

View File

@@ -1412,16 +1412,13 @@ static int wfreerdp_client_start(rdpContext* context)
static int wfreerdp_client_stop(rdpContext* context)
{
int rc;
wfContext* wfc = (wfContext*)context;
if (wfc->common.thread)
{
PostThreadMessage(wfc->mainThreadId, WM_QUIT, 0, 0);
WaitForSingleObject(wfc->common.thread, INFINITE);
CloseHandle(wfc->common.thread);
wfc->common.thread = NULL;
wfc->mainThreadId = 0;
}
WINPR_ASSERT(wfc);
PostThreadMessage(wfc->mainThreadId, WM_QUIT, 0, 0);
rc = freerdp_client_common_stop(context);
wfc->mainThreadId = 0;
if (wfc->keyboardThread)
{
@@ -1435,6 +1432,7 @@ static int wfreerdp_client_stop(rdpContext* context)
return 0;
}
int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
{
pEntryPoints->Version = 1;

View File

@@ -1906,24 +1906,6 @@ static int xfreerdp_client_start(rdpContext* context)
return 0;
}
static int xfreerdp_client_stop(rdpContext* context)
{
xfContext* xfc = (xfContext*)context;
WINPR_ASSERT(xfc);
freerdp_abort_connect(context->instance);
if (xfc->common.thread)
{
WaitForSingleObject(xfc->common.thread, INFINITE);
CloseHandle(xfc->common.thread);
xfc->common.thread = NULL;
}
return 0;
}
static Atom get_supported_atom(xfContext* xfc, const char* atomName)
{
unsigned long i;
@@ -2151,6 +2133,6 @@ int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
pEntryPoints->ClientNew = xfreerdp_client_new;
pEntryPoints->ClientFree = xfreerdp_client_free;
pEntryPoints->ClientStart = xfreerdp_client_start;
pEntryPoints->ClientStop = xfreerdp_client_stop;
pEntryPoints->ClientStop = freerdp_client_common_stop;
return 0;
}

View File

@@ -886,3 +886,20 @@ BOOL client_auto_reconnect_ex(freerdp* instance, BOOL (*window_events)(freerdp*
WLog_ERR(TAG, "Maximum reconnect retries exceeded");
return FALSE;
}
int freerdp_client_common_stop(rdpContext* context)
{
rdpClientContext* cctx = (rdpClientContext*)context;
WINPR_ASSERT(cctx);
freerdp_abort_connect(cctx->context.instance);
if (cctx->thread)
{
WaitForSingleObject(cctx->thread, INFINITE);
CloseHandle(cctx->thread);
cctx->thread = NULL;
}
return 0;
}

View File

@@ -146,6 +146,8 @@ extern "C"
FREERDP_API BOOL client_auto_reconnect_ex(freerdp* instance,
BOOL (*window_events)(freerdp* instance));
FREERDP_API int freerdp_client_common_stop(rdpContext* context);
#ifdef __cplusplus
}
#endif