From 441990d176ff6df7032ef812efb2ac35f4d76388 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Fri, 13 May 2016 17:00:44 -0400 Subject: The libhal RPC channel works better when one remembers to initialize it. --- pkcs11.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'pkcs11.c') 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; /* @@ -2453,6 +2454,15 @@ CK_RV C_Initialize(CK_VOID_PTR pInitArgs) if ((rv = mutex_create(&p11_global_mutex)) != CKR_OK) 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; -- cgit v1.2.3