summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--p11-kit/util.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/p11-kit/util.c b/p11-kit/util.c
index fd7708a..97a113b 100644
--- a/p11-kit/util.c
+++ b/p11-kit/util.c
@@ -275,19 +275,30 @@ _p11_library_get_thread_local (void)
return local;
}
+#ifdef __GNUC__
+__attribute__((constructor))
+#endif
void
_p11_library_init (void)
{
_p11_debug_init ();
+ _p11_debug ("initializing library");
_p11_mutex_init (&_p11_mutex);
pthread_key_create (&thread_local, free);
}
+#ifdef __GNUC__
+__attribute__((destructor))
+#endif
void
_p11_library_uninit (void)
{
uninit_common ();
+ /* Some cleanup to pacify valgrind */
+ free (pthread_getspecific (thread_local));
+ pthread_setspecific (thread_local, NULL);
+
pthread_key_delete (thread_local);
_p11_mutex_uninit (&_p11_mutex);
}