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

karl at svn.xiph.org karl at svn.xiph.org
Mon Apr 28 21:50:23 PDT 2008


Author: karl
Date: 2008-04-28 21:50:23 -0700 (Mon, 28 Apr 2008)
New Revision: 14812

Modified:
   icecast/trunk/icecast/src/admin.c
   icecast/trunk/icecast/src/fserve.c
   icecast/trunk/icecast/src/stats.c
   icecast/trunk/icecast/src/stats.h
Log:
Allow any number of mountpoints to be returned for streamlist. You would 
need a large number of mountpoints to trigger a truncation.  Allow file
serving thread to process a list of blocks for sending back to
the client. Then build the block list in the stats engine for returning.


Modified: icecast/trunk/icecast/src/admin.c
===================================================================
--- icecast/trunk/icecast/src/admin.c	2008-04-28 21:42:52 UTC (rev 14811)
+++ icecast/trunk/icecast/src/admin.c	2008-04-29 04:50:23 UTC (rev 14812)
@@ -995,17 +995,12 @@
 
     if (response == PLAINTEXT)
     {
-        char *buf;
-        int remaining = PER_CLIENT_REFBUF_SIZE;
-        int ret;
-
-        buf = client->refbuf->data;
-        ret = snprintf (buf, remaining,
+        snprintf (client->refbuf->data, PER_CLIENT_REFBUF_SIZE,
                 "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
-
-        stats_get_streamlist (client->refbuf->data+ret, remaining-ret);
-
         client->refbuf->len = strlen (client->refbuf->data);
+        client->respcode = 200;
+
+        client->refbuf->next = stats_get_streams ();
         fserve_add_client (client, NULL);
     }
     else

Modified: icecast/trunk/icecast/src/fserve.c
===================================================================
--- icecast/trunk/icecast/src/fserve.c	2008-04-28 21:42:52 UTC (rev 14811)
+++ icecast/trunk/icecast/src/fserve.c	2008-04-29 04:50:23 UTC (rev 14812)
@@ -262,13 +262,19 @@
                         bytes = 0;
                     if (bytes == 0)
                     {
-                        fserve_t *to_go = fclient;
-                        fclient = fclient->next;
-                        *trail = fclient;
-                        fserve_client_destroy (to_go);
-                        fserve_clients--;
-                        client_tree_changed = 1;
-                        continue;
+                        if (refbuf->next == NULL)
+                        {
+                            fserve_t *to_go = fclient;
+                            fclient = fclient->next;
+                            *trail = fclient;
+                            fserve_client_destroy (to_go);
+                            fserve_clients--;
+                            client_tree_changed = 1;
+                            continue;
+                        }
+                        client_set_queue (client, refbuf->next);
+                        refbuf = client->refbuf;
+                        bytes = refbuf->len;
                     }
                     refbuf->len = (unsigned int)bytes;
                     client->pos = 0;

Modified: icecast/trunk/icecast/src/stats.c
===================================================================
--- icecast/trunk/icecast/src/stats.c	2008-04-28 21:42:52 UTC (rev 14811)
+++ icecast/trunk/icecast/src/stats.c	2008-04-29 04:50:23 UTC (rev 14812)
@@ -1096,10 +1096,13 @@
 }
 
 
-/* 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)
+refbuf_t *stats_get_streams (void)
 {
+#define STREAMLIST_BLKSIZE  4096
     avl_node *node;
+    int remaining = STREAMLIST_BLKSIZE;
+    refbuf_t *start = refbuf_new (remaining), *cur = start;
+    char *buffer = cur->data;
 
     /* now the stats for each source */
     thread_mutex_lock (&_stats_mutex);
@@ -1111,10 +1114,13 @@
 
         if (source->hidden == 0)
         {
-            if (remaining <= strlen (source->source)+2)
+            if (remaining <= strlen (source->source) + 3)
             {
-                WARN0 ("streamlist was truncated");
-                break;
+                cur->len = STREAMLIST_BLKSIZE - remaining;
+                cur->next = refbuf_new (STREAMLIST_BLKSIZE);
+                remaining = STREAMLIST_BLKSIZE;
+                cur = cur->next;
+                buffer = cur->data;
             }
             ret = snprintf (buffer, remaining, "%s\r\n", source->source);
             if (ret > 0)
@@ -1123,12 +1129,15 @@
                 remaining -= ret;
             }
         }
-
         node = avl_get_next(node);
     }
     thread_mutex_unlock (&_stats_mutex);
+    cur->len = STREAMLIST_BLKSIZE - remaining;
+    return start;
 }
 
+
+
 /* This removes any source stats from virtual mountpoints, ie mountpoints
  * where no source_t exists. This function requires the global sources lock
  * to be held before calling.

Modified: icecast/trunk/icecast/src/stats.h
===================================================================
--- icecast/trunk/icecast/src/stats.h	2008-04-28 21:42:52 UTC (rev 14811)
+++ icecast/trunk/icecast/src/stats.h	2008-04-29 04:50:23 UTC (rev 14812)
@@ -76,7 +76,7 @@
 
 void stats_global(ice_config_t *config);
 stats_t *stats_get_stats(void);
-void stats_get_streamlist (char *buffer, size_t remaining);
+refbuf_t *stats_get_streams (void);
 void stats_clear_virtual_mounts (void);
 
 void stats_event(const char *source, const char *name, const char *value);



More information about the commits mailing list