* Implementation of public API timer functions.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <limits.h>
#include <pthread.h>
#include <stddef.h>
}
/* internal util method */
-static pcep_timers_context *create_timers_context_()
+static pcep_timers_context *create_timers_context_(void)
{
if (timers_context_ == NULL) {
timers_context_ = pceplib_malloc(PCEPLIB_INFRA,
/* Keeping this log for now, since in older versions of FRR the
* timer cancellation was blocking. This allows us to see how
* long the it takes.*/
- pcep_log(LOG_DEBUG, "%s: Reseting timer [%d] with callback",
+ pcep_log(LOG_DEBUG, "%s: Resetting timer [%d] with callback",
__func__, timer_to_reset->timer_id);
timers_context_->timer_cancel_func(
&timer_to_reset->external_timer);
}
pcep_timer *timer = (pcep_timer *)data;
+
pthread_mutex_lock(&timers_context_->timer_list_lock);
ordered_list_node *timer_node =
ordered_list_find2(timers_context_->timer_list, timer,
timer_list_node_timer_ptr_compare);
+
+ /* Remove timer from list */
+ if (timer_node)
+ ordered_list_remove_node2(timers_context_->timer_list,
+ timer_node);
+
pthread_mutex_unlock(&timers_context_->timer_list_lock);
/* Cannot continue if the timer does not exist */
timers_context_->expire_handler(timer->data, timer->timer_id);
- pthread_mutex_lock(&timers_context_->timer_list_lock);
- ordered_list_remove_node2(timers_context_->timer_list, timer_node);
- pthread_mutex_unlock(&timers_context_->timer_list_lock);
-
pceplib_free(PCEPLIB_INFRA, timer);
}