[xiph-commits] r7684 - icecast/branches/kh/icecast/src

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Thu Sep 2 07:00:28 PDT 2004


Author: karl
Date: 2004-09-02 07:00:27 -0700 (Thu, 02 Sep 2004)
New Revision: 7684

Modified:
   icecast/branches/kh/icecast/src/slave.c
   icecast/branches/kh/icecast/src/source.c
Log:
if fallback-override set on an on-demand relay and there are listeners on the
fallback mount then start the relay


Modified: icecast/branches/kh/icecast/src/slave.c
===================================================================
--- icecast/branches/kh/icecast/src/slave.c	2004-09-02 12:30:23 UTC (rev 7683)
+++ icecast/branches/kh/icecast/src/slave.c	2004-09-02 14:00:27 UTC (rev 7684)
@@ -334,6 +334,9 @@
             DEBUG1("Adding relay source at mountpoint \"%s\"", relay->localmount);
             if (relay->on_demand)
             {
+                ice_config_t *config = config_get_config ();
+                source_update_settings (config, relay->source);
+                config_release_config ();
                 stats_event (relay->localmount, NULL, NULL);
                 stats_event (relay->localmount, "listeners", "0");
                 DEBUG0 ("setting on_demand");
@@ -348,10 +351,28 @@
     }
     do
     {
+        source_t *source = relay->source;
         if (relay->source == NULL || relay->running)
             break;
-        if (relay->on_demand && relay->source->on_demand_req == 0)
-            break;
+        if (relay->on_demand)
+        {
+            DEBUG0 ("check fallback on-demand relay");
+            if (source->fallback_mount && source->fallback_override)
+            {
+                source_t *fallback;
+                avl_tree_rlock (global.source_tree);
+                DEBUG2 ("checking %s override %d", source->fallback_mount, source->fallback_override);
+                fallback = source_find_mount (source->fallback_mount);
+                if (fallback && fallback->running && fallback->listeners)
+                {
+                   DEBUG2 ("fallback running %d with %d listeners", fallback->running, fallback->listeners);
+                   source->on_demand_req = 1;
+                }
+                avl_tree_unlock (global.source_tree);
+            }
+            if (source->on_demand_req == 0)
+                break;
+        }
 
         relay->thread = thread_create ("Relay Thread", start_relay_stream,
                 relay, THREAD_ATTACHED);

Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c	2004-09-02 12:30:23 UTC (rev 7683)
+++ icecast/branches/kh/icecast/src/source.c	2004-09-02 14:00:27 UTC (rev 7684)
@@ -261,9 +261,6 @@
     util_dict_free (source->audio_info);
     source->audio_info = NULL;
 
-    free(source->fallback_mount);
-    source->fallback_mount = NULL;
-
     free(source->dumpfilename);
     source->dumpfilename = NULL;
 
@@ -285,6 +282,9 @@
     avl_delete (global.source_tree, source, NULL);
     avl_tree_unlock (global.source_tree);
 
+    free(source->fallback_mount);
+    source->fallback_mount = NULL;
+
     /* There should be no listeners on this mount */
     if (source->active_clients)
         WARN1("active listeners on mountpoint %s", source->mount);
@@ -393,6 +393,7 @@
         dest->check_pending = 1;
         source->listeners = 0;
         source->new_listeners = 0;
+        stats_event (source->mount, "listeners", "0");
 
     } while (0);
 
@@ -810,7 +811,6 @@
     DEBUG1 ("Added client to pending on %s", source->mount);
     source->check_pending = 1;
     stats_event_inc (NULL, "clients");
-    stats_event_inc (source->mount, "clients");
     return 0;
 }
 
@@ -1192,7 +1192,10 @@
     source->hidden = mountinfo->hidden;
 
     if (mountinfo->fallback_mount)
+    {
+        free (source->fallback_mount);
         source->fallback_mount = strdup (mountinfo->fallback_mount);
+    }
 
     if (mountinfo->auth_type != NULL)
     {
@@ -1201,7 +1204,10 @@
         stats_event(source->mount, "authenticator", mountinfo->auth_type);
     }
     if (mountinfo->dumpfile)
+    {
+        free (source->dumpfilename);
         source->dumpfilename = strdup (mountinfo->dumpfile);
+    }
 
     if (mountinfo->queue_size_limit)
         source->queue_size_limit = mountinfo->queue_size_limit;
@@ -1219,10 +1225,16 @@
         source->yp_prevent = 1;
 
     if (mountinfo->on_connect)
+    {
+        free (source->on_connect);
         source->on_connect = strdup(mountinfo->on_connect);
+    }
 
     if (mountinfo->on_disconnect)
+    {
+        free (source->on_disconnect);
         source->on_disconnect = strdup(mountinfo->on_disconnect);
+    }
 }
 
 



More information about the commits mailing list