1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

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.

svn path=/icecast/trunk/icecast/; revision=13496
This commit is contained in:
Karl Heyes 2007-08-09 15:43:00 +00:00
parent 7c6c79c416
commit 3e8f2c39d4
2 changed files with 6 additions and 4 deletions

View File

@ -249,9 +249,10 @@ void source_clear_source (source_t *source)
source->queue_size = 0; source->queue_size = 0;
source->queue_size_limit = 0; source->queue_size_limit = 0;
source->listeners = 0; source->listeners = 0;
source->shoutcast_compat = 0;
source->max_listeners = -1; source->max_listeners = -1;
source->prev_listeners = 0;
source->hidden = 0; source->hidden = 0;
source->shoutcast_compat = 0;
source->client_stats_update = 0; source->client_stats_update = 0;
util_dict_free (source->audio_info); util_dict_free (source->audio_info);
source->audio_info = NULL; source->audio_info = NULL;
@ -615,6 +616,7 @@ static void source_init (source_t *source)
DEBUG0("Source creation complete"); DEBUG0("Source creation complete");
source->last_read = time (NULL); source->last_read = time (NULL);
source->prev_listeners = -1;
source->running = 1; source->running = 1;
mountinfo = config_find_mount (config_get_config(), source->mount); mountinfo = config_find_mount (config_get_config(), source->mount);
@ -650,7 +652,6 @@ static void source_init (source_t *source)
void source_main (source_t *source) void source_main (source_t *source)
{ {
unsigned int listeners;
refbuf_t *refbuf; refbuf_t *refbuf;
client_t *client; client_t *client;
avl_node *client_node; avl_node *client_node;
@ -707,7 +708,6 @@ void source_main (source_t *source)
/* acquire write lock on client_tree */ /* acquire write lock on client_tree */
avl_tree_wlock(source->client_tree); avl_tree_wlock(source->client_tree);
listeners = source->listeners;
client_node = avl_get_first(source->client_tree); client_node = avl_get_first(source->client_tree);
while (client_node) { while (client_node) {
client = (client_t *)client_node->key; client = (client_t *)client_node->key;
@ -769,8 +769,9 @@ void source_main (source_t *source)
avl_tree_unlock(source->pending_tree); avl_tree_unlock(source->pending_tree);
/* update the stats if need be */ /* 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); INFO2("listener count on %s now %lu", source->mount, source->listeners);
if (source->listeners > source->peak_listeners) if (source->listeners > source->peak_listeners)
{ {

View File

@ -51,6 +51,7 @@ typedef struct source_tag
unsigned long peak_listeners; unsigned long peak_listeners;
unsigned long listeners; unsigned long listeners;
unsigned long prev_listeners;
long max_listeners; long max_listeners;
int yp_public; int yp_public;
int fallback_override; int fallback_override;