Add reference counting for client
[pazpar2-moved-to-github.git] / src / connection.c
index cbe26a1..196a397 100644 (file)
@@ -117,11 +117,12 @@ void connection_destroy(struct connection *co)
     }
     yaz_log(YLOG_DEBUG, "Connection destroy %s", co->host->hostport);
 
-    remove_connection_from_host(co);
     if (co->client)
     {
         client_disconnect(co->client);
     }
+
+    remove_connection_from_host(co);
     xfree(co->zproxy);
     xfree(co);
 }