aboutsummaryrefslogtreecommitdiff
path: root/pkcs11.c
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-05-13 17:00:44 -0400
committerRob Austein <sra@hactrn.net>2016-05-13 17:00:44 -0400
commit441990d176ff6df7032ef812efb2ac35f4d76388 (patch)
treeb93bcc4cb94f8878d1de6f391b6275b8e7ce9184 /pkcs11.c
parentf0556bb5c26c1d4198b0336be9f1f5dffcc3ea95 (diff)
The libhal RPC channel works better when one remembers to initialize it.
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;