Fix a race condition inside function alarm_cleanup() that
could be triggered during shutdown.
Also, fix few other issues:
* Add missing "timer_delete(akeup_timer)" statement inside
alarm_cleanup()
* Fix the argument when calling "timer_delete(timer)"
* Call "semaphore_free(alarm_expired)" inside alarm_cleanup()
after the corresponding "timer" and "wakeup_timer" have
been deleted.
* Fix the argument type when calling eventfd_read() inside
semaphore_wait()
Bug:
26982349
Change-Id: I2b00cd7ee7f56f755775f8e7b370006e31c6eb08
if (!alarms)
return;
- pthread_mutex_lock(&monitor);
-
dispatcher_thread_active = false;
semaphore_post(alarm_expired);
thread_free(dispatcher_thread);
dispatcher_thread = NULL;
+ pthread_mutex_lock(&monitor);
+
fixed_queue_free(default_callback_queue, NULL);
default_callback_queue = NULL;
thread_free(default_callback_thread);
default_callback_thread = NULL;
+ timer_delete(wakeup_timer);
+ timer_delete(timer);
semaphore_free(alarm_expired);
alarm_expired = NULL;
- timer_delete(&timer);
+
list_free(alarms);
alarms = NULL;
assert(semaphore != NULL);
assert(semaphore->fd != INVALID_FD);
- uint64_t value;
+ eventfd_t value;
if (eventfd_read(semaphore->fd, &value) == -1)
LOG_ERROR(LOG_TAG, "%s unable to wait on semaphore: %s", __func__, strerror(errno));
}