mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-11-03 04:17:17 -05:00
fix possible race when a stream shutdown occurs, causing stale YP enties in icecast
svn path=/icecast/branches/kh/icecast/; revision=7665
This commit is contained in:
parent
6bbb263b7d
commit
5f3f15f3ed
28
src/yp.c
28
src/yp.c
@ -55,6 +55,7 @@ struct yp_server
|
||||
typedef struct ypdata_tag
|
||||
{
|
||||
int remove;
|
||||
int release;
|
||||
int cmd_ok;
|
||||
|
||||
char *sid;
|
||||
@ -186,9 +187,9 @@ static void destroy_yp_server (struct yp_server *server)
|
||||
|
||||
|
||||
/* 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 @@ static void process_ypdata (struct yp_server *server, ypdata_t *yp)
|
||||
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 @@ void yp_remove (const char *mount)
|
||||
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 @@ void yp_touch (const char *mount)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user