From 342d4f2a3eb9f281e4e7c20c5daa3432f8a321ef Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 26 Apr 2010 13:11:30 +0200 Subject: [PATCH] Add facility to track total connections in use --- src/connection.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/connection.c b/src/connection.c index 4ca648e..8170590 100644 --- a/src/connection.c +++ b/src/connection.c @@ -47,6 +47,25 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "client.h" #include "settings.h" +/* connection counting (1) , disable connection counting (0) */ +#if 0 +static YAZ_MUTEX g_mutex = 0; +static int no_connections = 0; + +static void connection_use(int delta) +{ + if (!g_mutex) + yaz_mutex_create(&g_mutex); + yaz_mutex_enter(g_mutex); + no_connections += delta; + yaz_mutex_leave(g_mutex); + yaz_log(YLOG_LOG, "%s connections=%d", delta > 0 ? "INC" : "DEC", + no_connections); +} +#else +#define connection_use(x) +#endif + /** \brief Represents a physical, reusable connection to a remote Z39.50 host */ @@ -123,6 +142,7 @@ static void connection_destroy(struct connection *co) remove_connection_from_host(co); xfree(co->zproxy); xfree(co); + connection_use(-1); } // Creates a new connection for client, associated with the host of @@ -153,6 +173,7 @@ static struct connection *connection_create(struct client *cl, co->host->connections = co; yaz_mutex_leave(host->mutex); + connection_use(1); return co; } -- 1.7.10.4