Skip to content

Commit 3ab791a

Browse files
authored
Merge pull request #340 from parallaxsecond/session-not-send
Make Session Send
2 parents 2ed19d9 + d2a276c commit 3ab791a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cryptoki/src/session/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub use validation::ValidationFlagsType;
3838
pub struct Session {
3939
handle: CK_SESSION_HANDLE,
4040
client: Pkcs11,
41-
// This is not used but to prevent Session to automatically implement Send and Sync
41+
// This is not used but to prevent Session to automatically implement Sync
4242
_guard: PhantomData<*mut u32>,
4343
}
4444

@@ -60,6 +60,10 @@ impl std::fmt::UpperHex for Session {
6060
}
6161
}
6262

63+
// Session does not implement Sync to prevent the same Session instance to be used from multiple
64+
// threads. Send is allowed to let users pass a Session by ownership to threads.
65+
unsafe impl Send for Session {}
66+
6367
impl Session {
6468
pub(crate) fn new(handle: CK_SESSION_HANDLE, client: Pkcs11) -> Self {
6569
Session {

0 commit comments

Comments
 (0)