[xiph-cvs] cvs commit: icecast/src admin.c connection.c yp.c

Karl Heyes karl at xiph.org
Thu Feb 19 07:24:09 PST 2004



karl        04/02/19 10:24:08

  Modified:    src      admin.c connection.c yp.c
  Log:
  Add checks for whether a source is active

Revision  Changes    Path
1.23      +20 -11    icecast/src/admin.c

Index: admin.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/admin.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- admin.c	10 Feb 2004 03:50:39 -0000	1.22
+++ admin.c	19 Feb 2004 15:24:06 -0000	1.23
@@ -180,20 +180,21 @@
     node = avl_get_first(global.source_tree);
     while(node) {
         source = (source_t *)node->key;
-        srcnode = xmlNewChild(xmlnode, NULL, "source", NULL);
-        xmlSetProp(srcnode, "mount", source->mount);
+        if (source->running)
+        {
+            srcnode = xmlNewChild(xmlnode, NULL, "source", NULL);
+            xmlSetProp(srcnode, "mount", source->mount);
 
-        xmlNewChild(srcnode, NULL, "fallback", 
+            xmlNewChild(srcnode, NULL, "fallback", 
                     (source->fallback_mount != NULL)?
                     source->fallback_mount:"");
-        memset(buf, '\000', sizeof(buf));
-        snprintf(buf, sizeof(buf)-1, "%ld", source->listeners);
-        xmlNewChild(srcnode, NULL, "listeners", buf);
-        memset(buf, '\000', sizeof(buf));
-        snprintf(buf, sizeof(buf)-1, "%ld", now - source->con->con_time);
-        xmlNewChild(srcnode, NULL, "Connected", buf);
-        xmlNewChild(srcnode, NULL, "Format", 
-            source->format->format_description);
+            snprintf(buf, sizeof(buf), "%ld", source->listeners);
+            xmlNewChild(srcnode, NULL, "listeners", buf);
+            snprintf(buf, sizeof(buf), "%ld", now - source->con->con_time);
+            xmlNewChild(srcnode, NULL, "Connected", buf);
+            xmlNewChild(srcnode, NULL, "Format", 
+                    source->format->format_description);
+        }
         node = avl_get_next(node);
     }
     return(doc);
@@ -288,6 +289,14 @@
         }
         else
         {
+            if (source->running == 0)
+            {
+                INFO2("Received admin command %s on unavailable mount \"%s\"",
+                        command_string, mount);
+                avl_tree_unlock (global.source_tree);
+                client_send_400 (client, "Source is not available");
+                return;
+            }
             INFO2("Received admin command %s on mount \"%s\"", 
                     command_string, mount);
             admin_handle_mount_request(client, source, command);

<p><p>1.85      +7 -0      icecast/src/connection.c

Index: connection.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/connection.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- connection.c	29 Jan 2004 23:23:53 -0000	1.84
+++ connection.c	19 Feb 2004 15:24:06 -0000	1.85
@@ -884,6 +884,13 @@
             avl_tree_unlock(global.source_tree);
             return;
         }
+        if (source->running == 0)
+        {
+            avl_tree_unlock(global.source_tree);
+            DEBUG0("inactive source, client dropped");
+            client_send_404(client, "This mount is unavailable.");
+            return;
+        }
 
         /* Check for any required authentication first */
         if(source->authenticator != NULL) {

<p><p>1.18      +5 -0      icecast/src/yp.c

Index: yp.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/yp.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- yp.c	16 Feb 2004 21:59:08 -0000	1.17
+++ yp.c	19 Feb 2004 15:24:06 -0000	1.18
@@ -160,6 +160,11 @@
     node = avl_get_first(global.source_tree);
     while (node) {
         source = (source_t *)node->key;
+        if (source->running == 0)
+        {
+            node = avl_get_next (node);
+            continue;
+        }
         current_time = time(NULL);
         if (!source->yp_public) {
             node = avl_get_next(node);

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list