Add total connections. Enable connection count for now.
authorDennis Schafroth <dennis@indexdata.com>
Mon, 28 Mar 2011 11:34:00 +0000 (13:34 +0200)
committerDennis Schafroth <dennis@indexdata.com>
Mon, 28 Mar 2011 11:34:00 +0000 (13:34 +0200)
src/connection.c

index 012d994..c4dfe72 100644 (file)
@@ -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