X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fconnection.c;h=0a6f61c4d2e2e6964e2762808febe50c6bea7f2d;hb=ebf44db2f0c270b3ae1c25a5dc627f8e2a932da7;hp=12785b9ee13036e775769bd1bae4307bbcdc7030;hpb=9593a4408b5f2ebf87181d721ab93cecf97e5444;p=pazpar2-moved-to-github.git diff --git a/src/connection.c b/src/connection.c index 12785b9..0a6f61c 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2010 Index Data + Copyright (C) 2006-2011 Index Data Pazpar2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -48,22 +48,39 @@ 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) +static int connection_use(int delta) { + int result; if (!g_mutex) yaz_mutex_create(&g_mutex); yaz_mutex_enter(g_mutex); no_connections += delta; + result = no_connections; + 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(void) +{ + return connection_use(0); } + + #else #define connection_use(x) +#define connections_count(x) 0 +#define connections_count_total(x) 0 #endif @@ -423,7 +440,6 @@ static int connection_connect(struct connection *con, iochan_man_t iochan_man) if ((sru_version = session_setting_oneval(sdb, PZ_SRU_VERSION)) && *sru_version) ZOOM_options_set(zoptions, "sru_version", sru_version); - if (!(link = ZOOM_connection_create(zoptions))) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to create ZOOM Connection");