1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-11-03 04:17:17 -05:00

merge from branch, stats client details are not being removed when they exit

svn path=/icecast/trunk/icecast/; revision=9195
This commit is contained in:
Karl Heyes 2005-05-01 02:04:11 +00:00
parent acd1b8ad96
commit 9253bf7248

View File

@ -598,6 +598,25 @@ static void *_stats_thread(void *arg)
return NULL; return NULL;
} }
/* you must have the _stats_mutex locked here */
static void _unregister_listener(stats_event_t **queue)
{
event_listener_t **prev = (event_listener_t **)&_event_listeners,
*current = *prev;
while (current)
{
if (current->queue == queue)
{
*prev = current->next;
free (current);
break;
}
prev = &current->next;
current = *prev;
}
}
/* you must have the _stats_mutex locked here */ /* you must have the _stats_mutex locked here */
static void _register_listener(stats_event_t **queue, mutex_t *mutex) static void _register_listener(stats_event_t **queue, mutex_t *mutex)
{ {
@ -761,6 +780,8 @@ void *stats_connection(void *arg)
mutex_t local_event_mutex; mutex_t local_event_mutex;
stats_event_t *event; stats_event_t *event;
INFO0 ("stats client starting");
/* increment the thread count */ /* increment the thread count */
thread_mutex_lock(&_stats_mutex); thread_mutex_lock(&_stats_mutex);
_stats_threads++; _stats_threads++;
@ -789,12 +810,14 @@ void *stats_connection(void *arg)
thread_mutex_unlock(&local_event_mutex); thread_mutex_unlock(&local_event_mutex);
} }
thread_mutex_destroy(&local_event_mutex);
thread_mutex_lock(&_stats_mutex); thread_mutex_lock(&_stats_mutex);
_unregister_listener (&local_event_queue);
_stats_threads--; _stats_threads--;
thread_mutex_unlock(&_stats_mutex); thread_mutex_unlock(&_stats_mutex);
thread_mutex_destroy(&local_event_mutex);
INFO0 ("stats client finished");
return NULL; return NULL;
} }