[xiph-cvs] cvs commit: icecast/src format_mp3.c source.c source.h

Michael Smith msmith at xiph.org
Mon Dec 30 07:19:46 PST 2002



msmith      02/12/30 10:19:46

  Modified:    src      format_mp3.c source.c source.h
  Log:
  mountpoint fallbacks.
  untested, and no interface available to configure them.

Revision  Changes    Path
1.7       +1 -2      icecast/src/format_mp3.c

Index: format_mp3.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/format_mp3.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- format_mp3.c	30 Dec 2002 11:27:21 -0000	1.6
+++ format_mp3.c	30 Dec 2002 15:19:46 -0000	1.7
@@ -70,8 +70,6 @@
         return plugin;
 }
 
-/* TODO: need locking around source_state->metadata!! */
-
 static int send_metadata(client_t *client, mp3_client_data *client_state,
         mp3_state *source_state)
 {
@@ -217,6 +215,7 @@
     int bytes;
     
     client->respcode = 200;
+    /* TODO: This may need to be ICY/1.0 for shoutcast-compatibility? */
     bytes = sock_write(client->con->sock, 
             "HTTP/1.0 200 OK\r\n" 
             "Content-Type: %s\r\n", 

<p><p>1.26      +33 -2     icecast/src/source.c

Index: source.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/source.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- source.c	30 Dec 2002 07:55:56 -0000	1.25
+++ source.c	30 Dec 2002 15:19:46 -0000	1.26
@@ -94,6 +94,7 @@
         source_t *source = (source_t *)key;
 
         free(source->mount);
+    free(source->fallback_mount);
     client_destroy(source->client);
         avl_tree_free(source->pending_tree, _free_client);
         avl_tree_free(source->client_tree, _free_client);
@@ -107,6 +108,7 @@
 void *source_main(void *arg)
 {
         source_t *source = (source_t *)arg;
+    source_t *fallback_source;
         char buffer[4096];
         long bytes, sbytes;
         int ret, timeout;
@@ -346,15 +348,44 @@
 
     DEBUG0("Source exiting");
 
+    avl_tree_rlock(global.source_tree);
+    fallback_source = source_find_mount(source->fallback_mount);
+    avl_tree_unlock(global.source_tree);
+
         /* we need to empty the client and pending trees */
         avl_tree_wlock(source->pending_tree);
         while (avl_get_first(source->pending_tree)) {
-		avl_delete(source->pending_tree, avl_get_first(source->pending_tree)->key, _free_client);
+        client_t *client = (client_t *)avl_get_first(
+                source->pending_tree)->key;
+        if(fallback_source) {
+            avl_delete(source->pending_tree, client, _remove_client);
+
+            // TODO: reset client local format data? 
+            avl_tree_wlock(fallback_source->pending_tree);
+            avl_insert(fallback_source->pending_tree, (void *)client);
+            avl_tree_unlock(fallback_source->pending_tree);
+        }
+        else {
+    		avl_delete(source->pending_tree, client, _free_client);
+        }
         }
         avl_tree_unlock(source->pending_tree);
+
         avl_tree_wlock(source->client_tree);
         while (avl_get_first(source->client_tree)) {
-		avl_delete(source->client_tree, avl_get_first(source->client_tree)->key, _free_client);
+        client_t *client = (client_t *)avl_get_first(source->client_tree)->key;
+
+        if(fallback_source) {
+            avl_delete(source->client_tree, client, _remove_client);
+
+            // TODO: reset client local format data? 
+            avl_tree_wlock(fallback_source->pending_tree);
+            avl_insert(fallback_source->pending_tree, (void *)client);
+            avl_tree_unlock(fallback_source->pending_tree);
+        }
+        else {
+		    avl_delete(source->client_tree, client, _free_client);
+        }
         }
         avl_tree_unlock(source->client_tree);
 

<p><p>1.4       +4 -0      icecast/src/source.h

Index: source.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/source.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- source.h	30 Dec 2002 07:55:56 -0000	1.3
+++ source.h	30 Dec 2002 15:19:46 -0000	1.4
@@ -10,6 +10,10 @@
         http_parser_t *parser;
         
         char *mount;
+
+    /* If this source drops, try to move all clients to this fallback */
+    char *fallback_mount;
+
         struct _format_plugin_tag *format;
 
         avl_tree *client_tree;

<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