Commit 9253bf72 authored by Karl Heyes's avatar Karl Heyes

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

svn path=/icecast/trunk/icecast/; revision=9195
parent acd1b8ad
...@@ -598,6 +598,25 @@ static void *_stats_thread(void *arg) ...@@ -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) ...@@ -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) ...@@ -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;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment