Store the disconnect provider ulimatum reason in a new field in struct rdp_context and move the test for a logoff reason to xf_client.c

This commit is contained in:
rbarnett 2018-09-18 15:31:10 -05:00
parent 5db0b57fcd
commit 8458266183
4 changed files with 35 additions and 9 deletions

View File

@ -71,6 +71,13 @@
#include <freerdp/codec/color.h> #include <freerdp/codec/color.h>
#include <freerdp/codec/bitmap.h> #include <freerdp/codec/bitmap.h>
/*
* X11/Xlib.h defines Status, but winpr/rpc.h, which is eventually included by
* mcs.h, declares a few functions that have a parameter named Status.
*/
#undef Status
#include <libfreerdp/core/mcs.h>
#include <freerdp/utils/signal.h> #include <freerdp/utils/signal.h>
#include <freerdp/utils/passphrase.h> #include <freerdp/utils/passphrase.h>
#include <freerdp/client/cliprdr.h> #include <freerdp/client/cliprdr.h>
@ -101,6 +108,7 @@
#include "xf_channels.h" #include "xf_channels.h"
#include "xfreerdp.h" #include "xfreerdp.h"
#include <freerdp/log.h> #include <freerdp/log.h>
#define TAG CLIENT_TAG("x11") #define TAG CLIENT_TAG("x11")
@ -1631,8 +1639,18 @@ static DWORD WINAPI xf_client_thread(LPVOID param)
} }
if (!exit_code) if (!exit_code)
{
exit_code = freerdp_error_info(instance); exit_code = freerdp_error_info(instance);
if (exit_code == XF_EXIT_DISCONNECT && freerdp_get_dpu_reason(context) == MCS_Reason_user_requested)
{
/* This situation might be limited to Windows XP. */
WLog_INFO(TAG,
"Error info says user did not initiate but MCS ultimatum says they did; treat this as a user logoff");
exit_code = XF_EXIT_LOGOFF;
}
}
disconnect: disconnect:
if (timer) if (timer)

View File

@ -179,7 +179,8 @@ struct rdp_context
ALIGN64 rdpCodecs* codecs; /* 42 */ ALIGN64 rdpCodecs* codecs; /* 42 */
ALIGN64 rdpAutoDetect* autodetect; /* 43 */ ALIGN64 rdpAutoDetect* autodetect; /* 43 */
ALIGN64 HANDLE abortEvent; /* 44 */ ALIGN64 HANDLE abortEvent; /* 44 */
UINT64 paddingC[64 - 45]; /* 45 */ ALIGN64 int dpuReason; /* 45 */
UINT64 paddingC[64 - 46]; /* 46 */
UINT64 paddingD[96 - 64]; /* 64 */ UINT64 paddingD[96 - 64]; /* 64 */
UINT64 paddingE[128 - 96]; /* 96 */ UINT64 paddingE[128 - 96]; /* 96 */
@ -360,6 +361,9 @@ FREERDP_API void freerdp_free(freerdp* instance);
FREERDP_API BOOL freerdp_focus_required(freerdp* instance); FREERDP_API BOOL freerdp_focus_required(freerdp* instance);
FREERDP_API void freerdp_set_focus(freerdp* instance); FREERDP_API void freerdp_set_focus(freerdp* instance);
FREERDP_API int freerdp_get_dpu_reason(rdpContext* context);
FREERDP_API void freerdp_set_dpu_reason(rdpContext* context, int reason);
FREERDP_API UINT32 freerdp_get_last_error(rdpContext* context); FREERDP_API UINT32 freerdp_get_last_error(rdpContext* context);
FREERDP_API const char* freerdp_get_last_error_name(UINT32 error); FREERDP_API const char* freerdp_get_last_error_name(UINT32 error);
FREERDP_API const char* freerdp_get_last_error_string(UINT32 error); FREERDP_API const char* freerdp_get_last_error_string(UINT32 error);

View File

@ -658,6 +658,7 @@ BOOL freerdp_context_new(freerdp* instance)
context->instance = instance; context->instance = instance;
context->ServerMode = FALSE; context->ServerMode = FALSE;
context->settings = instance->settings; context->settings = instance->settings;
context->dpuReason = 0;
context->pubSub = PubSub_New(TRUE); context->pubSub = PubSub_New(TRUE);
if (!context->pubSub) if (!context->pubSub)
@ -760,6 +761,16 @@ void freerdp_context_free(freerdp* instance)
instance->context = NULL; instance->context = NULL;
} }
void freerdp_set_dpu_reason(rdpContext* context, int reason)
{
context->dpuReason = reason;
}
int freerdp_get_dpu_reason(rdpContext* context)
{
return context->dpuReason;
}
UINT32 freerdp_error_info(freerdp* instance) UINT32 freerdp_error_info(freerdp* instance)
{ {
return instance->context->rdp->errorInfo; return instance->context->rdp->errorInfo;

View File

@ -358,6 +358,7 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channelId)
return FALSE; return FALSE;
context = rdp->instance->context; context = rdp->instance->context;
freerdp_set_dpu_reason(context, reason);
if (rdp->errorInfo == ERRINFO_SUCCESS) if (rdp->errorInfo == ERRINFO_SUCCESS)
{ {
@ -373,14 +374,6 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channelId)
else else
rdp_set_error_info(rdp, ERRINFO_RPC_INITIATED_DISCONNECT); rdp_set_error_info(rdp, ERRINFO_RPC_INITIATED_DISCONNECT);
} }
else if ((rdp->errorInfo == ERRINFO_RPC_INITIATED_DISCONNECT) && (reason == MCS_Reason_user_requested))
{
/*
* This situation might be limited to Windows XP.
*/
WLog_INFO(TAG, "Error info says user did not initiate but MCS ultimatum sa they did; treat this as a user logoff");
rdp_set_error_info(rdp, ERRINFO_LOGOFF_BY_USER);
}
WLog_DBG(TAG, "DisconnectProviderUltimatum: reason: %d", reason); WLog_DBG(TAG, "DisconnectProviderUltimatum: reason: %d", reason);
freerdp_abort_connect(rdp->instance); freerdp_abort_connect(rdp->instance);