[xiph-commits] r14016 - icecast/trunk/icecast/src

karl at svn.xiph.org karl at svn.xiph.org
Fri Oct 19 17:58:06 PDT 2007


Author: karl
Date: 2007-10-19 17:58:05 -0700 (Fri, 19 Oct 2007)
New Revision: 14016

Modified:
   icecast/trunk/icecast/src/format.c
   icecast/trunk/icecast/src/source.c
   icecast/trunk/icecast/src/stats.c
   icecast/trunk/icecast/src/stats.h
Log:
add global listeners stat


Modified: icecast/trunk/icecast/src/format.c
===================================================================
--- icecast/trunk/icecast/src/format.c	2007-10-19 17:56:33 UTC (rev 14015)
+++ icecast/trunk/icecast/src/format.c	2007-10-20 00:58:05 UTC (rev 14016)
@@ -208,6 +208,7 @@
             client->con->error = 1;
             return -1;
         }
+        stats_event_inc (NULL, "listeners");
         stats_event_inc (NULL, "listener_connections");
         stats_event_inc (source->mount, "listener_connections");
     }

Modified: icecast/trunk/icecast/src/source.c
===================================================================
--- icecast/trunk/icecast/src/source.c	2007-10-19 17:56:33 UTC (rev 14015)
+++ icecast/trunk/icecast/src/source.c	2007-10-20 00:58:05 UTC (rev 14016)
@@ -212,6 +212,9 @@
         source->dumpfile = NULL;
     }
 
+    if (source->listeners)
+        stats_event_sub (NULL, "listeners", source->listeners);
+
     /* lets kick off any clients that are left on here */
     while (avl_get_first (source->client_tree))
     {
@@ -716,6 +719,7 @@
                 client_node = avl_get_next(client_node);
                 avl_delete(source->client_tree, (void *)client, _free_client);
                 source->listeners--;
+                stats_event_dec (NULL, "listeners");
                 DEBUG0("Client removed");
                 continue;
             }

Modified: icecast/trunk/icecast/src/stats.c
===================================================================
--- icecast/trunk/icecast/src/stats.c	2007-10-19 17:56:33 UTC (rev 14015)
+++ icecast/trunk/icecast/src/stats.c	2007-10-20 00:58:05 UTC (rev 14016)
@@ -49,8 +49,9 @@
 #define STATS_EVENT_INC     1
 #define STATS_EVENT_DEC     2
 #define STATS_EVENT_ADD     3
-#define STATS_EVENT_REMOVE  4
-#define STATS_EVENT_HIDDEN  5
+#define STATS_EVENT_SUB     4
+#define STATS_EVENT_REMOVE  5
+#define STATS_EVENT_HIDDEN  6
 
 typedef struct _event_queue_tag
 {
@@ -343,6 +344,18 @@
     }
 }
 
+void stats_event_sub(const char *source, const char *name, unsigned long value)
+{
+    stats_event_t *event = build_event (source, name, NULL);
+    if (event)
+    {
+        event->value = malloc (16);
+        snprintf (event->value, 16, "%ld", value);
+        event->action = STATS_EVENT_SUB;
+        queue_global_event (event);
+    }
+}
+
 /* decrease the value in the provided stat by 1 */
 void stats_event_dec(const char *source, const char *name)
 {
@@ -609,6 +622,7 @@
     stats_event (NULL, "connections", "0");
     stats_event (NULL, "sources", "0");
     stats_event (NULL, "stats", "0");
+    stats_event (NULL, "listeners", "0");
 
     /* global accumulating stats */
     stats_event (NULL, "client_connections", "0");

Modified: icecast/trunk/icecast/src/stats.h
===================================================================
--- icecast/trunk/icecast/src/stats.h	2007-10-19 17:56:33 UTC (rev 14015)
+++ icecast/trunk/icecast/src/stats.h	2007-10-20 00:58:05 UTC (rev 14016)
@@ -85,6 +85,7 @@
 void stats_event_args(const char *source, char *name, char *format, ...);
 void stats_event_inc(const char *source, const char *name);
 void stats_event_add(const char *source, const char *name, unsigned long value);
+void stats_event_sub(const char *source, const char *name, unsigned long value);
 void stats_event_dec(const char *source, const char *name);
 void stats_event_hidden (const char *source, const char *name, int hidden);
 void stats_event_time (const char *mount, const char *name);



More information about the commits mailing list