conf_get_fname takes conf_config as arg
[pazpar2-moved-to-github.git] / src / database.c
index 8ffbee2..ab425c7 100644 (file)
@@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <yaz/log.h>
 #include <yaz/nmem.h>
 
+#include "ppmutex.h"
 #include "session.h"
 #include "host.h"
 #include "pazpar2_config.h"
@@ -109,7 +110,7 @@ static struct host *create_host(const char *hostport, iochan_man_t iochan_man)
         xfree(host);
         return 0;
     }
-    yaz_mutex_create(&host->mutex);
+    pazpar2_mutex_create(&host->mutex, "host");
 
     return host;
 }
@@ -410,10 +411,29 @@ database_hosts_t database_hosts_create(void)
     database_hosts_t p = xmalloc(sizeof(*p));
     p->hosts = 0;
     p->mutex = 0;
-    yaz_mutex_create(&p->mutex);
+    pazpar2_mutex_create(&p->mutex, "database");
     return p;
 }
 
+void database_hosts_destroy(database_hosts_t *pp)
+{
+    if (*pp)
+    {
+        struct host *p = (*pp)->hosts;
+        while (p)
+        {
+            struct host *p_next = p->next;
+            yaz_mutex_destroy(&p->mutex);
+            xfree(p->ipport);
+            xfree(p->hostport);
+            xfree(p);
+            p = p_next;
+        }
+        yaz_mutex_destroy(&(*pp)->mutex);
+        xfree(*pp);
+    }
+}
+
 /*
  * Local variables:
  * c-basic-offset: 4