+void client_incref(struct client *c)
+{
+ pazpar2_incref(&c->ref_count, c->mutex);
+ yaz_log(YLOG_LOG, "client_incref c=%p %s cnt=%d",
+ c, client_get_url(c), c->ref_count);
+}
+
+int client_destroy(struct client *c)
+{
+ if (c)
+ {
+ yaz_log(YLOG_LOG, "client_destroy c=%p %s cnt=%d",
+ c, client_get_url(c), c->ref_count);
+ if (!pazpar2_decref(&c->ref_count, c->mutex))
+ {
+ xfree(c->pquery);
+ c->pquery = 0;
+ xfree(c->cqlquery);
+ c->cqlquery = 0;
+ assert(!c->connection);
+ assert(!c->resultset);
+
+ yaz_mutex_destroy(&c->mutex);
+ xfree(c);
+ client_use(-1);
+ return 1;
+ }
+ }
+ return 0;