]> git.proxmox.com Git - mirror_frr.git/blobdiff - pceplib/pcep_timers.c
Merge pull request #11162 from anlancs/fix/bgpd-cleanup-5
[mirror_frr.git] / pceplib / pcep_timers.c
index e9d9d4b21d9a8991750a8e290a79b5df8ae93e3e..b0f3e70b50dcd861b800f33b1ffda0a348ed2a8a 100644 (file)
  *  Implementation of public API timer functions.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <limits.h>
 #include <pthread.h>
 #include <stddef.h>
@@ -71,7 +75,7 @@ int timer_list_node_timer_ptr_compare(void *list_entry, void *new_entry)
 }
 
 /* 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,
@@ -409,7 +413,7 @@ bool reset_timer(int timer_id)
                /* 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);
@@ -457,10 +461,17 @@ void pceplib_external_timer_expire_handler(void *data)
        }
 
        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 */
@@ -474,9 +485,5 @@ void pceplib_external_timer_expire_handler(void *data)
 
        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);
 }