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

karl at svn.xiph.org karl at svn.xiph.org
Thu Aug 9 16:36:29 PDT 2007


Author: karl
Date: 2007-08-09 16:36:29 -0700 (Thu, 09 Aug 2007)
New Revision: 13500

Modified:
   icecast/trunk/icecast/src/admin.c
   icecast/trunk/icecast/src/stats.c
   icecast/trunk/icecast/src/stats.h
Log:
Update the streamlist handler for slaves. Get the list of non-hidden mountpoints
from the stats engine instead of the mount or source list, as the stats are
populated by non-mount defined streams and mounts with active fallbacks.


Modified: icecast/trunk/icecast/src/admin.c
===================================================================
--- icecast/trunk/icecast/src/admin.c	2007-08-09 20:38:04 UTC (rev 13499)
+++ icecast/trunk/icecast/src/admin.c	2007-08-09 23:36:29 UTC (rev 13500)
@@ -968,52 +968,24 @@
 {
     DEBUG0("List mounts request");
 
-    avl_tree_rlock (global.source_tree);
     if (response == PLAINTEXT)
     {
         char *buf;
         int remaining = PER_CLIENT_REFBUF_SIZE;
         int ret;
-        ice_config_t *config = config_get_config ();
-        mount_proxy *mountinfo = config->mounts;
 
         buf = client->refbuf->data;
         ret = snprintf (buf, remaining,
                 "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
 
-        while (mountinfo && ret > 0 && ret < remaining)
-        {
-            mount_proxy *current = mountinfo;
-            source_t *source;
-            mountinfo = mountinfo->next;
+        stats_get_streamlist (client->refbuf->data+ret, remaining-ret);
 
-            /* now check that a source is available */
-            source = source_find_mount (current->mountname);
-
-            if (source == NULL)
-                continue;
-            if (source->running == 0 && source->on_demand == 0)
-                continue;
-            if (source->hidden)
-                continue;
-            remaining -= ret;
-            buf += ret;
-            ret = snprintf (buf, remaining, "%s\n", current->mountname);
-        }
-        avl_tree_unlock (global.source_tree);
-        config_release_config();
-
-        /* handle last line */
-        if (ret > 0 && ret < remaining)
-        {
-            remaining -= ret;
-            buf += ret;
-        }
-        client->refbuf->len = PER_CLIENT_REFBUF_SIZE - remaining;
+        client->refbuf->len = strlen (client->refbuf->data);
         fserve_add_client (client, NULL);
     }
     else
     {
+        avl_tree_rlock (global.source_tree);
         xmlDocPtr doc = admin_build_sourcelist(NULL);
         avl_tree_unlock (global.source_tree);
 

Modified: icecast/trunk/icecast/src/stats.c
===================================================================
--- icecast/trunk/icecast/src/stats.c	2007-08-09 20:38:04 UTC (rev 13499)
+++ icecast/trunk/icecast/src/stats.c	2007-08-09 23:36:29 UTC (rev 13500)
@@ -1027,3 +1027,38 @@
     if (event->value) free(event->value);
     free(event);
 }
+
+
+/* get a list of mountpoints that are in the stats but are not marked as hidden */
+void stats_get_streamlist (char *buffer, size_t remaining)
+{
+    avl_node *node;
+
+    /* now the stats for each source */
+    thread_mutex_lock (&_stats_mutex);
+    node = avl_get_first(_stats.source_tree);
+    while (node)
+    {
+        int ret;
+        stats_source_t *source = (stats_source_t *)node->key;
+
+        if (source->hidden == 0)
+        {
+            if (remaining <= strlen (source->source)+2)
+            {
+                WARN0 ("streamlist was truncated");
+                break;
+            }
+            ret = snprintf (buffer, remaining, "%s\r\n", source->source);
+            if (ret > 0)
+            {
+                buffer += ret;
+                remaining -= ret;
+            }
+        }
+
+        node = avl_get_next(node);
+    }
+    thread_mutex_unlock (&_stats_mutex);
+}
+

Modified: icecast/trunk/icecast/src/stats.h
===================================================================
--- icecast/trunk/icecast/src/stats.h	2007-08-09 20:38:04 UTC (rev 13499)
+++ icecast/trunk/icecast/src/stats.h	2007-08-09 23:36:29 UTC (rev 13500)
@@ -74,6 +74,7 @@
 void stats_shutdown(void);
 
 stats_t *stats_get_stats(void);
+void stats_get_streamlist (char *buffer, size_t remaining);
 
 void stats_event(const char *source, const char *name, const char *value);
 void stats_event_args(const char *source, char *name, char *format, ...);



More information about the commits mailing list