From 9c480acecf1029fbba916a3f56ca902b9272e24b Mon Sep 17 00:00:00 2001 From: irungentoo_trip Date: Sat, 25 Oct 2014 09:01:15 -0700 Subject: Fixed possible threading issues. --- toxav/msi.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/toxav/msi.c b/toxav/msi.c index 138c8d3f..4445f567 100644 --- a/toxav/msi.c +++ b/toxav/msi.c @@ -486,7 +486,7 @@ struct timer_function_args { * @param timeout Timeout in ms * @return int */ -static int timer_alloc ( TimerHandler *timers_container, void *(func)(void *), void *arg1, int arg2, uint32_t timeout) +static int timer_alloc ( TimerHandler *timers_container, void * (func)(void *), void *arg1, int arg2, uint32_t timeout) { static int timer_id; pthread_mutex_lock(&timers_container->mutex); @@ -631,6 +631,15 @@ static void *timer_poll( void *arg ) usleep(handler->resolution); } + size_t i = 0; + + for (; i < handler->max_capacity; i ++) + free(handler->timers[i]); + + free(handler->timers); + + pthread_mutex_destroy( &handler->mutex ); + free(handler); pthread_exit(NULL); } @@ -691,15 +700,6 @@ static void timer_terminate_session(TimerHandler *handler) handler->running = 0; pthread_mutex_unlock(&handler->mutex); - - size_t i = 0; - - for (; i < handler->max_capacity; i ++) - free(handler->timers[i]); - - free(handler->timers); - - pthread_mutex_destroy( &handler->mutex ); } /** -- cgit v1.2.3