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

Karl Heyes karl at xiph.org
Wed Feb 25 13:43:53 PST 2004



karl        04/02/25 16:43:53

  Modified:    src      admin.c
  Log:
  add missing lock on source tree

Revision  Changes    Path
1.26      +25 -10    icecast/src/admin.c

Index: admin.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/admin.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- admin.c	25 Feb 2004 20:11:31 -0000	1.25
+++ admin.c	25 Feb 2004 21:43:52 -0000	1.26
@@ -699,28 +699,43 @@
     return;
 }
 
-static void command_list_mounts(client_t *client, int response) {
-    xmlDocPtr doc;
+static void command_list_mounts(client_t *client, int response)
+{
     avl_node *node;
     source_t *source;
 
     DEBUG0("List mounts request");
 
-
+    avl_tree_rlock (global.source_tree);
     if (response == PLAINTEXT)
     {
+        char buffer [4096], *buf = buffer;
+        unsigned remaining = sizeof (buffer);
+        int ret = sprintf (buffer,
+                "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
+
         node = avl_get_first(global.source_tree);
-		html_write(client, 
-            "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
-        while(node) {
+        while (node && ret > 0 && ret < remaining)
+        {
+            remaining -= ret;
+            buf += ret;
             source = (source_t *)node->key;
-            html_write(client, "%s\n", source->mount);
+            ret = snprintf (buf, remaining, "%s\n", source->mount);
             node = avl_get_next(node);
         }
+        avl_tree_unlock (global.source_tree);
+        /* handle last line */
+        if (ret > 0 && ret < remaining)
+        {
+            remaining -= ret;
+            buf += ret;
+        }
+        sock_write_bytes (client->con->sock, buffer, sizeof (buffer)-remaining);
     }
-    else {
-
-        doc = admin_build_sourcelist(NULL);
+    else
+    {
+        xmlDocPtr doc = admin_build_sourcelist(NULL);
+        avl_tree_unlock (global.source_tree);
 
         admin_send_response(doc, client, response, 
             LISTMOUNTS_TRANSFORMED_REQUEST);

<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