summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo_trip <irungentoo@gmail.com>2014-10-25 09:01:15 -0700
committerirungentoo_trip <irungentoo@gmail.com>2014-10-25 09:01:15 -0700
commit9c480acecf1029fbba916a3f56ca902b9272e24b (patch)
treee761a9fb99b90ef3aa6849dd8a9f0a7976cbd1eb
parent9b5aa3ff27531d233bfffdc4aa8c835e2729c15e (diff)
Fixed possible threading issues.
-rw-r--r--toxav/msi.c20
1 files 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 {
486 * @param timeout Timeout in ms 486 * @param timeout Timeout in ms
487 * @return int 487 * @return int
488 */ 488 */
489static int timer_alloc ( TimerHandler *timers_container, void *(func)(void *), void *arg1, int arg2, uint32_t timeout) 489static int timer_alloc ( TimerHandler *timers_container, void * (func)(void *), void *arg1, int arg2, uint32_t timeout)
490{ 490{
491 static int timer_id; 491 static int timer_id;
492 pthread_mutex_lock(&timers_container->mutex); 492 pthread_mutex_lock(&timers_container->mutex);
@@ -631,6 +631,15 @@ static void *timer_poll( void *arg )
631 usleep(handler->resolution); 631 usleep(handler->resolution);
632 } 632 }
633 633
634 size_t i = 0;
635
636 for (; i < handler->max_capacity; i ++)
637 free(handler->timers[i]);
638
639 free(handler->timers);
640
641 pthread_mutex_destroy( &handler->mutex );
642
634 free(handler); 643 free(handler);
635 pthread_exit(NULL); 644 pthread_exit(NULL);
636} 645}
@@ -691,15 +700,6 @@ static void timer_terminate_session(TimerHandler *handler)
691 handler->running = 0; 700 handler->running = 0;
692 701
693 pthread_mutex_unlock(&handler->mutex); 702 pthread_mutex_unlock(&handler->mutex);
694
695 size_t i = 0;
696
697 for (; i < handler->max_capacity; i ++)
698 free(handler->timers[i]);
699
700 free(handler->timers);
701
702 pthread_mutex_destroy( &handler->mutex );
703} 703}
704 704
705/** 705/**