aboutsummaryrefslogtreecommitdiff
path: root/pkcs11.c
diff options
context:
space:
mode:
Diffstat (limited to 'pkcs11.c')
-rw-r--r--pkcs11.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/pkcs11.c b/pkcs11.c
index dc14fd9..10b9034 100644
--- a/pkcs11.c
+++ b/pkcs11.c
@@ -2361,6 +2361,7 @@ CK_RV C_Initialize(CK_VOID_PTR pInitArgs)
CK_C_INITIALIZE_ARGS_PTR a = pInitArgs;
int initialized_sql = 0;
+ int initialized_rpc = 0;
CK_RV rv;
/*
@@ -2454,6 +2455,15 @@ CK_RV C_Initialize(CK_VOID_PTR pInitArgs)
goto fail;
/*
+ * Initialize libhal RPC channel.
+ */
+
+ if (!hal_check(hal_rpc_client_init()))
+ lose(CKR_GENERAL_ERROR);
+
+ initialized_rpc = 1;
+
+ /*
* Initialize SQLite3, opening the database(s) and loading the
* schema and views.
*/
@@ -2474,6 +2484,9 @@ CK_RV C_Initialize(CK_VOID_PTR pInitArgs)
if (initialized_sql)
sql_fini();
+ if (initialized_rpc)
+ hal_rpc_client_close();
+
return rv;
}
@@ -2503,9 +2516,11 @@ CK_RV C_Finalize(CK_VOID_PTR pReserved)
/*
* By this point we're pretty well committed to shutting down, so
- * there's not much to be done if these mutex operations fail.
+ * there's not much to be done if any of the rest of this fails.
*/
+ hal_rpc_client_close();
+
rv = mutex_unlock(p11_global_mutex);
(void) mutex_destroy(p11_global_mutex);
p11_global_mutex = NULL;