Initialize mutexes correctly in mock module
authorStef Walter <stefw@gnome.org>
Tue, 17 Jul 2012 06:09:16 +0000 (08:09 +0200)
committerStef Walter <stefw@gnome.org>
Thu, 26 Jul 2012 10:22:31 +0000 (12:22 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=44740

tests/mock-module-ep.c
tests/mock-module.c

index c784546042168e5540db6890595174988a7aa5d8..7440a741e4ba24915f1e67e2d7a33a9c84df7274 100644 (file)
@@ -44,6 +44,7 @@ __declspec(dllexport)
 CK_RV
 C_GetFunctionList (CK_FUNCTION_LIST_PTR_PTR list)
 {
+       mock_module_init ();
        if (list == NULL)
                return CKR_ARGUMENTS_BAD;
        *list = &mock_module_no_slots;
index 36515d07a5f1479e39b68bbeb159a9c5000f17ae..99cde5053b47ccbdee859c6b862999102c70ceca 100644 (file)
@@ -890,5 +890,9 @@ CK_FUNCTION_LIST mock_module_no_slots = {
 void
 mock_module_init (void)
 {
-       _p11_mutex_init (&init_mutex);
+       static int initialized = 0;
+       if (!initialized) {
+               _p11_mutex_init (&init_mutex);
+               initialized = 1;
+       }
 }