No more reachable memory with yaz_deinit_globals
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 9 Nov 2015 12:29:01 +0000 (13:29 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 9 Nov 2015 12:29:01 +0000 (13:29 +0100)
At least when nettle is in use (libgcrypt is hopeless)

src/init_globals.c
src/log.c

index ea3a565..4d3804d 100644 (file)
@@ -45,6 +45,7 @@ static pthread_mutex_t yaz_init_mutex = PTHREAD_MUTEX_INITIALIZER;
 #endif
 
 extern void yaz_log_init_globals(void);
+extern void yaz_log_deinit_globals(void);
 
 #if HAVE_GCRYPT_H
 GCRY_THREAD_OPTION_PTHREAD_IMPL;
@@ -99,7 +100,7 @@ void yaz_deinit_globals(void)
 #endif
     if (yaz_init_flag)
     {
-        yaz_log_init_file(0);
+        yaz_log_deinit_globals();
 #if HAVE_GNUTLS_H
         gnutls_global_deinit();
 #endif
index d005378..4edead7 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -154,6 +154,15 @@ void yaz_log_close(void)
     }
 }
 
+void yaz_log_deinit_globals(void)
+{
+    if (log_mutex)
+    {
+        yaz_mutex_destroy(&log_mutex);
+        yaz_log_close();
+    }
+}
+
 void yaz_log_init_file(const char *fname)
 {
     yaz_init_globals();