+#if 1
+static YAZ_MUTEX g_mutex = 0;
+static int no_iochans = 0;
+static int no_iochans_total = 0;
+
+static int iochan_use(int delta)
+{
+ int iochans;
+ if (!g_mutex)
+ yaz_mutex_create(&g_mutex);
+ yaz_mutex_enter(g_mutex);
+ no_iochans += delta;
+ if (delta > 0)
+ no_iochans_total += delta;
+ iochans = no_iochans;
+ yaz_mutex_leave(g_mutex);
+ yaz_log(YLOG_DEBUG, "%s iochans=%d", delta == 0 ? "" : (delta > 0 ? "INC" : "DEC"), iochans);
+ return iochans;
+}
+
+int iochans_count(void) {
+ return iochan_use(0);
+}
+
+int iochans_count_total(void) {
+ int total = 0;
+ if (!g_mutex)
+ return 0;
+ yaz_mutex_enter(g_mutex);
+ total = no_iochans_total;
+ yaz_mutex_leave(g_mutex);
+ return total;
+}
+#else
+#define iochan_use(x)
+#define iochans_count(x) 0
+#define iochans_count_total(x) 0
+#endif
+