mirror of https://github.com/FreeRDP/FreeRDP
Cache Emulate_IsConfigured result (#7569)
* Cache Emulate_IsConfigured result The check is used very often, so this caching reduces necessary allocations. * Fix winpr_HexLogDump Abort function early if the log message is to be discarded due to the log level being inactive. * Use common logger for rdpdr message Co-authored-by: Martin Fleisz <martin.fleisz@thincast.com>
This commit is contained in:
parent
9c7ec3888a
commit
a337031b24
|
@ -51,6 +51,10 @@ struct smartcard_emulation_context
|
|||
wLog* log;
|
||||
wHashTable* contexts;
|
||||
wHashTable* handles;
|
||||
BOOL configured;
|
||||
const char* pem;
|
||||
const char* key;
|
||||
const char* pin;
|
||||
};
|
||||
|
||||
#define MAX_EMULATED_READERS 1
|
||||
|
@ -2682,24 +2686,31 @@ BOOL Emulate_IsConfigured(SmartcardEmulationContext* context)
|
|||
{
|
||||
BOOL rc = FALSE;
|
||||
vgidsContext* vgids;
|
||||
const char* pem = NULL;
|
||||
const char* key = NULL;
|
||||
const char* pin = NULL;
|
||||
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
pem = freerdp_settings_get_string(context->settings, FreeRDP_SmartcardCertificate);
|
||||
key = freerdp_settings_get_string(context->settings, FreeRDP_SmartcardPrivateKey);
|
||||
|
||||
if (freerdp_settings_get_bool(context->settings, FreeRDP_PasswordIsSmartcardPin))
|
||||
pin = freerdp_settings_get_string(context->settings, FreeRDP_Password);
|
||||
|
||||
/* Cache result only, if no initialization arguments changed. */
|
||||
if ((context->pem == pem) && (context->key == key) && (context->pin == pin))
|
||||
return context->configured;
|
||||
|
||||
context->pem = pem;
|
||||
context->key = key;
|
||||
context->pin = pin;
|
||||
|
||||
vgids = vgids_new();
|
||||
if (vgids)
|
||||
{
|
||||
const char* pem =
|
||||
freerdp_settings_get_string(context->settings, FreeRDP_SmartcardCertificate);
|
||||
const char* key =
|
||||
freerdp_settings_get_string(context->settings, FreeRDP_SmartcardPrivateKey);
|
||||
const char* pin = NULL;
|
||||
|
||||
if (freerdp_settings_get_bool(context->settings, FreeRDP_PasswordIsSmartcardPin))
|
||||
pin = freerdp_settings_get_string(context->settings, FreeRDP_Password);
|
||||
|
||||
rc = vgids_init(vgids, pem, key, pin);
|
||||
}
|
||||
|
||||
rc = vgids_init(vgids, context->pem, context->key, context->pin);
|
||||
vgids_free(vgids);
|
||||
|
||||
context->configured = rc;
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -282,6 +282,7 @@ void rdpdr_dump_received_packet(wStream* s, const char* custom)
|
|||
UINT32 MajorFunction = 0;
|
||||
UINT32 MinorFunction = 0;
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
wLog* log = WLog_Get(TAG);
|
||||
|
||||
Stream_Read_UINT16(s, component);
|
||||
Stream_Read_UINT16(s, packetid);
|
||||
|
@ -298,14 +299,14 @@ void rdpdr_dump_received_packet(wStream* s, const char* custom)
|
|||
Stream_Read_UINT32(s, MajorFunction); /* MajorFunction (4 bytes) */
|
||||
Stream_Read_UINT32(s, MinorFunction); /* MinorFunction (4 bytes) */
|
||||
|
||||
WLog_DBG(TAG,
|
||||
"[%s] receive [%s | %s] [0x%08" PRIx32 "] FileID=0x%08" PRIx32
|
||||
", CompletionID=0x%08" PRIx32 ", MajorFunction=%s [0x%08" PRIx32
|
||||
"] -> %" PRIuz,
|
||||
custom, rdpdr_component_string(component),
|
||||
rdpdr_packetid_string(packetid), deviceID, FileId, CompletionId,
|
||||
rdpdr_irp_string(MajorFunction), MinorFunction, deviceID,
|
||||
Stream_Length(s));
|
||||
WLog_Print(log, WLOG_DEBUG,
|
||||
"[%s] receive [%s | %s] [0x%08" PRIx32 "] FileID=0x%08" PRIx32
|
||||
", CompletionID=0x%08" PRIx32 ", MajorFunction=%s [0x%08" PRIx32
|
||||
"] -> %" PRIuz,
|
||||
custom, rdpdr_component_string(component),
|
||||
rdpdr_packetid_string(packetid), deviceID, FileId, CompletionId,
|
||||
rdpdr_irp_string(MajorFunction), MinorFunction, deviceID,
|
||||
Stream_Length(s));
|
||||
done = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -314,11 +315,11 @@ void rdpdr_dump_received_packet(wStream* s, const char* custom)
|
|||
|
||||
if (!done)
|
||||
{
|
||||
WLog_DBG(TAG, "[%s] receive [%s | %s] [0x%08" PRIx32 "] -> %" PRIuz, custom,
|
||||
rdpdr_component_string(component), rdpdr_packetid_string(packetid), deviceID,
|
||||
Stream_Length(s));
|
||||
WLog_Print(log, WLOG_DEBUG, "[%s] receive [%s | %s] [0x%08" PRIx32 "] -> %" PRIuz,
|
||||
custom, rdpdr_component_string(component), rdpdr_packetid_string(packetid),
|
||||
deviceID, Stream_Length(s));
|
||||
}
|
||||
winpr_HexDump(TAG, WLOG_TRACE, Stream_Buffer(s), Stream_Length(s));
|
||||
winpr_HexLogDump(log, WLOG_TRACE, Stream_Buffer(s), Stream_Length(s));
|
||||
}
|
||||
|
||||
Stream_SetPosition(s, pos);
|
||||
|
|
|
@ -61,6 +61,9 @@ void winpr_HexLogDump(wLog* log, UINT32 lvl, const BYTE* data, size_t length)
|
|||
|
||||
char* buffer;
|
||||
|
||||
if (!WLog_IsLevelActive(log, lvl))
|
||||
return;
|
||||
|
||||
if (!log || (maxlen < 0))
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue