From d198c3e4680783a435adb274a88506e6c7386c32 Mon Sep 17 00:00:00 2001 From: Anton Burticica Date: Tue, 14 Jan 2025 21:11:28 +0200 Subject: [PATCH] Disable tracing::instrument for C_Finalize/C_CloseAllSesssions --- native-pkcs11/src/lib.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/native-pkcs11/src/lib.rs b/native-pkcs11/src/lib.rs index d51b4ed..28dc9da 100644 --- a/native-pkcs11/src/lib.rs +++ b/native-pkcs11/src/lib.rs @@ -251,16 +251,17 @@ cryptoki_fn!( } ); -cryptoki_fn!( - fn C_Finalize(pReserved: CK_VOID_PTR) { +pub extern "C" fn C_Finalize(pReserved: CK_VOID_PTR) -> CK_RV { + // TODO(bweeks): should this be `expr` instead of `block`? + result_to_rv(|| { initialized!(); if !pReserved.is_null() { return Err(Error::ArgumentsBad); } INITIALIZED.store(false, Ordering::SeqCst); Ok(()) - } -); + }) +} cryptoki_fn!( unsafe fn C_GetInfo(pInfo: CK_INFO_PTR) { @@ -474,14 +475,16 @@ cryptoki_fn!( } ); -cryptoki_fn!( - fn C_CloseAllSessions(slotID: CK_SLOT_ID) { +#[no_mangle] +pub extern "C" fn C_CloseAllSessions(slotID: CK_SLOT_ID) -> CK_RV { + // TODO(bweeks): should this be `expr` instead of `block`? + result_to_rv(|| { initialized!(); valid_slot!(slotID); sessions::close_all(); Ok(()) - } -); + }) +} cryptoki_fn!( unsafe fn C_GetSessionInfo(hSession: CK_SESSION_HANDLE, pInfo: CK_SESSION_INFO_PTR) {