Skip to content

Commit

Permalink
Attempt to fix CI with C_Finalize clearing the DEVICE
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Sep 4, 2024
1 parent 1275093 commit bac9733
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkcs11/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub extern "C" fn C_Finalize(pReserved: CK_VOID_PTR) -> CK_RV {
if !pReserved.is_null() {
return cryptoki_sys::CKR_ARGUMENTS_BAD;
}
// FIXME: Clear the `DEVICE` to `None` to close all connections properly
DEVICE.store(None);
EVENTS_MANAGER.write().unwrap().finalized = true;

cryptoki_sys::CKR_OK
Expand Down
6 changes: 2 additions & 4 deletions pkcs11/src/backend/slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ pub fn get_slot(slot_id: usize) -> Result<Arc<Slot>, cryptoki_sys::CK_RV> {
#[cfg(test)]
pub fn init_for_tests() {
use std::ptr;
use std::sync::Once;

use crate::api::C_Initialize;

static ONCE: Once = Once::new();
ONCE.call_once(|| {
if DEVICE.load().is_none() {
std::env::set_var("P11NETHSM_CONFIG_FILE", "../p11nethsm.conf");
assert_eq!(C_Initialize(ptr::null_mut()), cryptoki_sys::CKR_OK);
})
}
}

0 comments on commit bac9733

Please sign in to comment.