[core,peer] improve logging

log unhandled data in peer_recv_callback as warning if the loop
terminates.
This commit is contained in:
akallabeth 2024-01-09 16:18:57 +01:00 committed by Martin Fleisz
parent 2e42d8ac2b
commit a612463c96

View File

@ -1159,6 +1159,10 @@ static state_run_t peer_recv_callback(rdpTransport* transport, wStream* s, void*
state_run_t rc = STATE_RUN_FAILED;
const size_t start = Stream_GetPosition(s);
const rdpContext* context = transport_get_context(transport);
DWORD level = WLOG_TRACE;
static wLog* log = NULL;
if (!log)
log = WLog_Get(TAG);
WINPR_ASSERT(context);
do
@ -1170,9 +1174,13 @@ static state_run_t peer_recv_callback(rdpTransport* transport, wStream* s, void*
Stream_SetPosition(s, start);
rc = peer_recv_callback_internal(transport, s, extra);
WLog_VRB(TAG, "(server)[%s -> %s] current return %s [%" PRIuz " bytes not processed]", old,
rdp_get_state_string(rdp), state_run_result_string(rc, buffer, sizeof(buffer)),
Stream_GetRemainingLength(s));
const size_t len = Stream_GetRemainingLength(s);
if ((len > 0) && !state_run_continue(rc))
level = WLOG_WARN;
WLog_Print(log, level,
"(server)[%s -> %s] current return %s [%" PRIuz " bytes not processed]", old,
rdp_get_state_string(rdp), state_run_result_string(rc, buffer, sizeof(buffer)),
len);
} while (state_run_continue(rc));
return rc;