From 1a87ba8fc22170954b503e6c5ae369c2f0e7f7e6 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 26 Jan 2023 14:51:09 +0100 Subject: [PATCH] [core,server] add state STATE_RUN_QUIT_SESSION If a session is terminated indicate this by STATE_RUN_QUIT_SESSION instead of setting STATE_RUN_FAILED which would imply some failure --- libfreerdp/core/peer.c | 7 ++++++- libfreerdp/core/state.c | 12 +++++++++++- libfreerdp/core/state.h | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index f04eb869b..1d86a0260 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -385,7 +385,8 @@ static state_run_t peer_recv_data_pdu(freerdp_peer* client, wStream* s, UINT16 t case DATA_PDU_TYPE_SHUTDOWN_REQUEST: mcs_send_disconnect_provider_ultimatum(client->context->rdp->mcs); - return STATE_RUN_FAILED; + WLog_WARN(TAG, "disconnect provider ultimatum sent to peer, closing connection"); + return STATE_RUN_QUIT_SESSION; case DATA_PDU_TYPE_FRAME_ACKNOWLEDGE: if (!Stream_CheckAndLogRequiredLength(TAG, s, 4)) @@ -759,6 +760,7 @@ static state_run_t rdp_peer_handle_state_active(freerdp_peer* client) } if (!client->connected) { + WLog_ERR(TAG, "PostConnect for peer %p failed", client); ret = STATE_RUN_FAILED; } else if (!client->activated) @@ -772,7 +774,10 @@ static state_run_t rdp_peer_handle_state_active(freerdp_peer* client) IFCALLRET(client->Activate, activated, client); if (!activated) + { + WLog_ERR(TAG, "Activate for peer %p failed", client); ret = STATE_RUN_FAILED; + } else ret = STATE_RUN_SUCCESS; } diff --git a/libfreerdp/core/state.c b/libfreerdp/core/state.c index ce3d5d6d3..e4ca138b9 100644 --- a/libfreerdp/core/state.c +++ b/libfreerdp/core/state.c @@ -25,7 +25,14 @@ BOOL state_run_failed(state_run_t status) { - return status == STATE_RUN_FAILED; + switch (status) + { + case STATE_RUN_FAILED: + case STATE_RUN_QUIT_SESSION: + return TRUE; + default: + return FALSE; + } } BOOL state_run_success(state_run_t status) @@ -53,6 +60,9 @@ const char* state_run_result_string(state_run_t status, char* buffer, size_t buf case STATE_RUN_FAILED: name = "STATE_RUN_FAILED"; break; + case STATE_RUN_QUIT_SESSION: + name = "STATE_RUN_QUIT_SESSION"; + break; case STATE_RUN_TRY_AGAIN: name = "STATE_RUN_TRY_AGAIN"; break; diff --git a/libfreerdp/core/state.h b/libfreerdp/core/state.h index ed8f868cf..2cb000356 100644 --- a/libfreerdp/core/state.h +++ b/libfreerdp/core/state.h @@ -31,6 +31,7 @@ typedef enum STATE_RUN_REDIRECT = 1, STATE_RUN_SUCCESS = 0, STATE_RUN_FAILED = -1, + STATE_RUN_QUIT_SESSION = -2, STATE_RUN_TRY_AGAIN = -23, STATE_RUN_CONTINUE = -24 } state_run_t;