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

karl at svn.xiph.org karl at svn.xiph.org
Thu Aug 9 08:43:01 PDT 2007


Author: karl
Date: 2007-08-09 08:43:00 -0700 (Thu, 09 Aug 2007)
New Revision: 13496

Modified:
   icecast/trunk/icecast/src/source.c
   icecast/trunk/icecast/src/source.h
Log:
fix problem case when listeners are moved by another thread, eg a fallback
override is triggered, and on-demand relays are not shut down or stats are
not updated.


Modified: icecast/trunk/icecast/src/source.c
===================================================================
--- icecast/trunk/icecast/src/source.c	2007-08-09 12:24:33 UTC (rev 13495)
+++ icecast/trunk/icecast/src/source.c	2007-08-09 15:43:00 UTC (rev 13496)
@@ -249,9 +249,10 @@
     source->queue_size = 0;
     source->queue_size_limit = 0;
     source->listeners = 0;
-    source->shoutcast_compat = 0;
     source->max_listeners = -1;
+    source->prev_listeners = 0;
     source->hidden = 0;
+    source->shoutcast_compat = 0;
     source->client_stats_update = 0;
     util_dict_free (source->audio_info);
     source->audio_info = NULL;
@@ -615,6 +616,7 @@
 
     DEBUG0("Source creation complete");
     source->last_read = time (NULL);
+    source->prev_listeners = -1;
     source->running = 1;
 
     mountinfo = config_find_mount (config_get_config(), source->mount);
@@ -650,7 +652,6 @@
 
 void source_main (source_t *source)
 {
-    unsigned int listeners;
     refbuf_t *refbuf;
     client_t *client;
     avl_node *client_node;
@@ -707,7 +708,6 @@
         /* acquire write lock on client_tree */
         avl_tree_wlock(source->client_tree);
 
-        listeners = source->listeners;
         client_node = avl_get_first(source->client_tree);
         while (client_node) {
             client = (client_t *)client_node->key;
@@ -769,8 +769,9 @@
         avl_tree_unlock(source->pending_tree);
 
         /* update the stats if need be */
-        if (source->listeners != listeners)
+        if (source->listeners != source->prev_listeners)
         {
+            source->prev_listeners = source->listeners;
             INFO2("listener count on %s now %lu", source->mount, source->listeners);
             if (source->listeners > source->peak_listeners)
             {

Modified: icecast/trunk/icecast/src/source.h
===================================================================
--- icecast/trunk/icecast/src/source.h	2007-08-09 12:24:33 UTC (rev 13495)
+++ icecast/trunk/icecast/src/source.h	2007-08-09 15:43:00 UTC (rev 13496)
@@ -51,6 +51,7 @@
 
     unsigned long peak_listeners;
     unsigned long listeners;
+    unsigned long prev_listeners;
     long max_listeners;
     int yp_public;
     int fallback_override;



More information about the commits mailing list