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

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Mon Aug 30 09:47:24 PDT 2004


Author: karl
Date: 2004-08-30 09:47:23 -0700 (Mon, 30 Aug 2004)
New Revision: 7665

Modified:
   icecast/branches/kh/icecast/src/yp.c
Log:
fix possible race when a stream shutdown occurs, causing stale YP enties in icecast


Modified: icecast/branches/kh/icecast/src/yp.c
===================================================================
--- icecast/branches/kh/icecast/src/yp.c	2004-08-30 14:38:18 UTC (rev 7664)
+++ icecast/branches/kh/icecast/src/yp.c	2004-08-30 16:47:23 UTC (rev 7665)
@@ -55,6 +55,7 @@
 typedef struct ypdata_tag
 {
     int remove;
+    int release;
     int cmd_ok;
 
     char *sid;
@@ -186,9 +187,9 @@
 
 
 /* search for a ypdata entry corresponding to a specific mountpoint */
-static ypdata_t *find_yp_mount (struct yp_server *server, const char *mount)
+static ypdata_t *find_yp_mount (ypdata_t *mounts, const char *mount)
 {
-    ypdata_t *yp = server->mounts;
+    ypdata_t *yp = mounts;
     while (yp)
     {
         if (strcmp (yp->mount, mount) == 0)
@@ -412,6 +413,11 @@
             return;
         s = tmp;
 
+        if (yp->release)
+        {
+            yp->process = do_yp_remove;
+            yp->next_update = 0;
+        }
         ret = yp->process (yp, s, len);
         if (ret == 0)
         {
@@ -853,11 +859,11 @@
     thread_rwlock_rlock (&yp_lock);
     while (server)
     {
-        ypdata_t *yp = find_yp_mount (server, mount);
+        ypdata_t *yp = find_yp_mount (server->mounts, mount);
         if (yp)
         {
-            DEBUG2 ("mark %s on YP %s", mount, server->url);
-            yp->process = do_yp_remove;
+            DEBUG2 ("release %s on YP %s", mount, server->url);
+            yp->release = 1;
             yp->next_update = 0;
         }
         server = server->next;
@@ -872,20 +878,30 @@
 {
     struct yp_server *server = active_yps;
     time_t trigger;
+    ypdata_t *search_list;
 
     thread_rwlock_rlock (&yp_lock);
     /* do update in 3 secs, give stats chance to update */
     trigger = time(NULL) + 3;
+    search_list = server->mounts;
     while (server)
     {
-        ypdata_t *yp = find_yp_mount (server, mount);
+        ypdata_t *yp = find_yp_mount (search_list, mount);
         if (yp)
         {
+            /* we may of found entries not purged yet, so skip them */
+            if (yp->release == 0 || yp->remove == 0)
+            {
+                search_list = yp->next;
+                continue;
+            }
             /* only force if touch */
             if (yp->process == do_yp_touch)
                 yp->next_update = trigger;
         }
         server = server->next;
+        if (server)
+            search_list = server->mounts;
     }
     thread_rwlock_unlock (&yp_lock);
 }



More information about the commits mailing list