From 7c05c7abdb8633dea7e5120d10f01bef55da66db Mon Sep 17 00:00:00 2001 From: Dennis Schafroth Date: Mon, 28 Mar 2011 13:34:00 +0200 Subject: [PATCH] Add total connections. Enable connection count for now. --- src/connection.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/connection.c b/src/connection.c index 012d994..c4dfe72 100644 --- a/src/connection.c +++ b/src/connection.c @@ -48,22 +48,37 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "settings.h" /* connection counting (1) , disable connection counting (0) */ -#if 0 +#if 1 static YAZ_MUTEX g_mutex = 0; static int no_connections = 0; - +static int total_no_connections = 0; static void connection_use(int delta) { + int result; if (!g_mutex) yaz_mutex_create(&g_mutex); yaz_mutex_enter(g_mutex); no_connections += delta; + result = no_connection; + if (delta > 0) + total_no_connections += delta; yaz_mutex_leave(g_mutex); + if (delta == 0) + return result; yaz_log(YLOG_LOG, "%s connections=%d", delta > 0 ? "INC" : "DEC", no_connections); + return result; +} + +int connections_count() { + return connection_use(0); } + + #else #define connection_use(x) +#define connections_count(x) 0 +#define connections_count_total(x) 0 #endif -- 1.7.10.4