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

karl at svn.xiph.org karl at svn.xiph.org
Tue Mar 14 18:42:21 PST 2006


Author: karl
Date: 2006-03-14 18:42:18 -0800 (Tue, 14 Mar 2006)
New Revision: 11007

Modified:
   icecast/trunk/icecast/src/source.c
Log:
When modifying source_t contents we should take a write lock to prevent
races with other threads. so take a write lock on the client tree.


Modified: icecast/trunk/icecast/src/source.c
===================================================================
--- icecast/trunk/icecast/src/source.c	2006-03-15 02:34:39 UTC (rev 11006)
+++ icecast/trunk/icecast/src/source.c	2006-03-15 02:42:18 UTC (rev 11007)
@@ -194,6 +194,8 @@
 void source_clear_source (source_t *source)
 {
     DEBUG1 ("clearing source \"%s\"", source->mount);
+
+    avl_tree_wlock (source->client_tree);
     client_destroy(source->client);
     source->client = NULL;
     source->parser = NULL;
@@ -211,15 +213,13 @@
     }
 
     /* lets kick off any clients that are left on here */
-    avl_tree_rlock (source->client_tree);
     while (avl_get_first (source->client_tree))
     {
         avl_delete (source->client_tree,
                 avl_get_first (source->client_tree)->key, _free_client);
     }
-    avl_tree_unlock (source->client_tree);
 
-    avl_tree_rlock (source->pending_tree);
+    avl_tree_wlock (source->pending_tree);
     while (avl_get_first (source->pending_tree))
     {
         avl_delete (source->pending_tree,
@@ -269,6 +269,7 @@
     }
 
     source->on_demand_req = 0;
+    avl_tree_unlock (source->client_tree);
 }
 
 
@@ -935,6 +936,7 @@
     http_parser_t *parser = NULL;
 
     DEBUG1("Applying mount information for \"%s\"", source->mount);
+    avl_tree_rlock (source->client_tree);
     if (mountinfo)
     {
         source->max_listeners = mountinfo->max_listeners;
@@ -1133,6 +1135,7 @@
 
     if (source->format && source->format->apply_settings)
         source->format->apply_settings (source->client, source->format, mountinfo);
+    avl_tree_unlock (source->client_tree);
 }
 
 



More information about the commits mailing list