Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP3:Update
openCryptoki
ocki-3.6.2-Token-individual-locking-PATCH-04-04...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ocki-3.6.2-Token-individual-locking-PATCH-04-04.patch of Package openCryptoki
Opencryptoki process locking rework Backported version of the token individual locking patches. commit 37ddac38ec35b70820f1da3f8e27e4092809a22b Author: Ingo Tuchscherer <ingo.tuchscherer@linux.vnet.ibm.com> Date: Thu Sep 28 16:54:26 2017 +0200 Token individual locking (4 patches) Each token gets his own lockfile. The file handle is stored in the token individual data structure. The locking functions are called with token individual lockfiles. Signed-off-by: Ingo Tuchscherer <ingo.tuchscherer@linux.vnet.ibm.com> Signed-off-by: Harald Freudenberger <freude@linux.ibm.com> --- usr/lib/pkcs11/api/api_interface.c | 20 ++++++++++---------- usr/lib/pkcs11/api/apiproto.h | 8 ++++---- usr/lib/pkcs11/api/apiutil.c | 36 ++++++++++++++++++------------------ 3 files changed, 32 insertions(+), 32 deletions(-) --- a/usr/lib/pkcs11/api/api_interface.c +++ b/usr/lib/pkcs11/api/api_interface.c @@ -1701,7 +1701,7 @@ CK_RV C_Finalize(CK_VOID_PTR pReserved) trace_finalize(); //close the lock file descriptor here to avoid memory leak - XProcClose(); + ProcClose(); DestroyAPILock(); @@ -3039,7 +3039,7 @@ CK_RV C_Initialize(CK_VOID_PTR pVoid) } // Create the shared memory lock. - if (CreateXProcLock() != CKR_OK) { + if (CreateProcLock() != CKR_OK) { free((void *)Anchor); Anchor = NULL; TRACE_ERROR("Process Lock Failed.\n"); @@ -4586,7 +4586,7 @@ C_WaitForSlotEvent(CK_FLAGS flags, CK_SL // REally should be the procp->proc_mutex // but this is such an infrequent thing that we will simply get // the global shared memory lock - XProcLock(); + ProcLock(); if (procp->slotmap) { // find the first bit set // This will have to change if more than 32 slots ever get supported @@ -4597,11 +4597,11 @@ C_WaitForSlotEvent(CK_FLAGS flags, CK_SL } } *pSlot = i; // set the flag - XProcUnLock(); + ProcUnLock(); return CKR_OK; } else { if (flags & CKF_DONT_BLOCK) { - XProcUnLock(); + ProcUnLock(); return CKR_NO_EVENT; } else { // WE need to @@ -4616,14 +4616,14 @@ C_WaitForSlotEvent(CK_FLAGS flags, CK_SL // We will choose to fail the call. if (procp->blocking) { TRACE_DEVEL("WaitForSlot event called by process twice.\n"); - XProcUnLock(); // Unlock aftersetting + ProcUnLock(); // Unlock aftersetting TRACE_ERROR("%s\n", ock_err(ERR_FUNCTION_FAILED)); return CKR_FUNCTION_FAILED; } procp->error = 0; procp->blocking = 0x01; - XProcUnLock(); // Unlock aftersetting + ProcUnLock(); // Unlock aftersetting // NOTE: We need to have an asynchronous mechanism for // the slot manager to wake up anyone blocking on this. @@ -4633,10 +4633,10 @@ C_WaitForSlotEvent(CK_FLAGS flags, CK_SL while (!procp->slotmap && !procp->error) { sleep(1); // Note This is really bad form. But what the heck } - XProcLock(); + ProcLock(); procp->blocking = 0; if (procp->error) { - XProcUnLock(); + ProcUnLock(); TRACE_ERROR("%s\n", ock_err(ERR_GENERAL_ERROR)); return CKR_GENERAL_ERROR; // We bailed on this because we were terminating // General error should cause the calling thread to not try anything @@ -4649,7 +4649,7 @@ C_WaitForSlotEvent(CK_FLAGS flags, CK_SL } } *pSlot = i; // set the flag - XProcUnLock(); + ProcUnLock(); return CKR_OK; } } --- a/usr/lib/pkcs11/api/apiproto.h +++ b/usr/lib/pkcs11/api/apiproto.h @@ -317,10 +317,10 @@ void API_UnRegister(); int DL_Load_and_Init(API_Slot_t *, CK_SLOT_ID); -CK_RV CreateXProcLock(void); -CK_RV XProcLock(void); -CK_RV XProcUnLock(void); -CK_RV XProcClose(void); +CK_RV CreateProcLock(void); +CK_RV ProcLock(void); +CK_RV ProcUnLock(void); +CK_RV ProcClose(void); CK_RV CreateAPILock(); CK_RV DestroyAPILock(); --- a/usr/lib/pkcs11/api/apiutil.c +++ b/usr/lib/pkcs11/api/apiutil.c @@ -329,7 +329,7 @@ extern API_Proc_Struct_t *Anchor; #include <stdarg.h> #include "trace.h" -CK_RV CreateXProcLock(void) +CK_RV CreateProcLock(void) { struct stat statbuf; @@ -351,7 +351,7 @@ CK_RV CreateXProcLock(void) return CKR_OK; } -CK_RV XProcLock(void) +CK_RV ProcLock(void) { if (xplfd != -1) flock(xplfd, LOCK_EX); @@ -361,7 +361,7 @@ CK_RV XProcLock(void) return CKR_OK; } -CK_RV XProcUnLock(void) +CK_RV ProcUnLock(void) { if (xplfd != -1) flock(xplfd, LOCK_UN); @@ -371,12 +371,12 @@ CK_RV XProcUnLock(void) return CKR_OK; } -CK_RV XProcClose(void) +CK_RV ProcClose(void) { if (xplfd != -1) close(xplfd); else - TRACE_DEVEL("XProcClose: No file descriptor open to close.\n"); + TRACE_DEVEL("ProcClose: No file descriptor open to close.\n"); return CKR_OK; } @@ -543,9 +543,9 @@ void get_sess_count(CK_SLOT_ID slotID, C Slot_Mgr_Shr_t *shm; shm = Anchor->SharedMemP; - XProcLock(); + ProcLock(); *ret = shm->slot_global_sessions[slotID]; - XProcUnLock(); + ProcUnLock(); } void incr_sess_counts(CK_SLOT_ID slotID) @@ -560,14 +560,14 @@ void incr_sess_counts(CK_SLOT_ID slotID) // Get the slot mutex shm = Anchor->SharedMemP; - XProcLock(); + ProcLock(); shm->slot_global_sessions[slotID]++; procp = &shm->proc_table[Anchor->MgrProcIndex]; procp->slot_session_count[slotID]++; - XProcUnLock(); + ProcUnLock(); } @@ -583,7 +583,7 @@ void decr_sess_counts(CK_SLOT_ID slotID) // Get the slot mutex shm = Anchor->SharedMemP; - XProcLock(); + ProcLock(); if (shm->slot_global_sessions[slotID] > 0) { shm->slot_global_sessions[slotID]--; @@ -594,7 +594,7 @@ void decr_sess_counts(CK_SLOT_ID slotID) procp->slot_session_count[slotID]++; } - XProcUnLock(); + ProcUnLock(); } @@ -613,9 +613,9 @@ int sessions_exist(CK_SLOT_ID slotID) // Get the slot mutex shm = Anchor->SharedMemP; - XProcLock(); + ProcLock(); numSessions = shm->slot_global_sessions[slotID]; - XProcUnLock(); + ProcUnLock(); return numSessions != 0; } @@ -676,7 +676,7 @@ int API_Register() shm = Anchor->SharedMemP; - XProcLock(); + ProcLock(); procp = shm->proc_table; for (indx = 0; indx < NUMBER_PROCESSES_ALLOWED; indx++, procp++) { @@ -708,7 +708,7 @@ int API_Register() // If we did not find a free entry then we fail the routine if ((reuse == -1) && (free == -1)) { - XProcUnLock(); + ProcUnLock(); return FALSE; } // check if we are reusing a control block or taking the first free. @@ -742,7 +742,7 @@ int API_Register() //Does initializing them in the slotd allow for them to not be //initialized in the application. - XProcUnLock(); + ProcUnLock(); return TRUE; } @@ -770,7 +770,7 @@ void API_UnRegister() shm = Anchor->SharedMemP; - XProcLock(); + ProcLock(); procp = &(shm->proc_table[Anchor->MgrProcIndex]); @@ -786,7 +786,7 @@ void API_UnRegister() //Does initializing them in the slotd allow for them to not be //initialized in the application. - XProcUnLock(); + ProcUnLock(); }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor