mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixed possible threading issues.
This commit is contained in:
parent
9b5aa3ff27
commit
9c480acecf
20
toxav/msi.c
20
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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user