allocate some cookies to reduce unknown timers
authorHannes Gredler <hannes@gredler.at>
Mon, 10 Nov 2008 14:33:38 +0000 (15:33 +0100)
committerHannes Gredler <hannes@gredler.at>
Mon, 10 Nov 2008 14:33:38 +0000 (15:33 +0100)
src/link_set.c
src/lq_plugin_default_ff.c
src/main.c
src/olsr.c
src/olsr_spf.c
src/olsr_spf.h
src/tc_set.c
src/tc_set.h

index ab2a678..5cc279b 100644 (file)
 /* head node for all link sets */
 struct list_node link_entry_head;
 
+static struct olsr_cookie_info *link_dead_timer_cookie = NULL;
+static struct olsr_cookie_info *link_loss_timer_cookie = NULL;
+static struct olsr_cookie_info *link_sym_timer_cookie = NULL;
+
+
 olsr_bool link_changes;                       /* is set if changes occur in MPRS set */
 
 void
@@ -83,6 +88,14 @@ olsr_init_link_set(void)
 
   /* Init list head */
   list_head_init(&link_entry_head);
+
+  link_dead_timer_cookie =
+    olsr_alloc_cookie("Link dead", OLSR_COOKIE_TYPE_TIMER);
+  link_loss_timer_cookie =
+    olsr_alloc_cookie("Link loss", OLSR_COOKIE_TYPE_TIMER);
+  link_sym_timer_cookie =
+    olsr_alloc_cookie("Link SYM", OLSR_COOKIE_TYPE_TIMER);
+
 }
 
 
@@ -476,7 +489,8 @@ void
 olsr_set_link_timer(struct link_entry *link, unsigned int rel_timer)
 {
   olsr_set_timer(&link->link_timer, rel_timer, OLSR_LINK_JITTER,
-                OLSR_TIMER_ONESHOT, &olsr_expire_link_entry, link, 0);
+                OLSR_TIMER_ONESHOT, &olsr_expire_link_entry, link,
+                 link_dead_timer_cookie->ci_id);
 }
 
 /**
@@ -566,7 +580,8 @@ add_link_entry(const union olsr_ip_addr *local,
 
     olsr_set_timer(&new_link->link_loss_timer, htime + htime/2,
                   OLSR_LINK_LOSS_JITTER, OLSR_TIMER_PERIODIC,
-                  &olsr_expire_link_loss_timer, new_link, 0);
+                  &olsr_expire_link_loss_timer, new_link,
+                   link_loss_timer_cookie->ci_id);
 
     set_loss_link_multiplier(new_link);
   }
@@ -695,7 +710,8 @@ update_link_entry(const union olsr_ip_addr *local,
     /* L_SYM_time = current time + validity time */
     olsr_set_timer(&entry->link_sym_timer, message->vtime,
                   OLSR_LINK_SYM_JITTER, OLSR_TIMER_ONESHOT,
-                  &olsr_expire_link_sym_timer, entry, 0);
+                  &olsr_expire_link_sym_timer, entry,
+                   link_sym_timer_cookie->ci_id);
 
     /* L_time = L_SYM_time + NEIGHB_HOLD_TIME */
     olsr_set_link_timer(entry, message->vtime + NEIGHB_HOLD_TIME *
@@ -832,7 +848,8 @@ olsr_update_packet_loss(struct link_entry *entry)
   /* timeout for the first lost packet is 1.5 x htime */
   olsr_set_timer(&entry->link_loss_timer, entry->loss_helloint + entry->loss_helloint/2,
                 OLSR_LINK_LOSS_JITTER, OLSR_TIMER_PERIODIC,
-                &olsr_expire_link_loss_timer, entry, 0);
+                &olsr_expire_link_loss_timer, entry,
+                 link_loss_timer_cookie->ci_id);
 }
 
 /*
index ba19d1e..b3f041b 100644 (file)
@@ -179,8 +179,14 @@ static void default_lq_ff_timer(void __attribute__((unused)) *context) {
 }
 
 void default_lq_initialize_ff(void) {
+  /* Some cookies for stats keeping */
+  static struct olsr_cookie_info *default_lq_ff_timer_cookie = NULL;
+
   olsr_packetparser_add_function(&default_lq_parser_ff);
-  olsr_start_timer(1000, 0, OLSR_TIMER_PERIODIC, &default_lq_ff_timer, NULL, 0);
+  default_lq_ff_timer_cookie = olsr_alloc_cookie("Default Freifunk LQ",
+                                                 OLSR_COOKIE_TYPE_TIMER);
+  olsr_start_timer(1000, 0, OLSR_TIMER_PERIODIC, &default_lq_ff_timer, NULL,
+                   default_lq_ff_timer_cookie->ci_id);
 }
 
 olsr_linkcost default_lq_calc_cost_ff(const void *ptr) {
index 83d36d3..a510531 100644 (file)
@@ -102,6 +102,10 @@ static char copyright_string[] __attribute__((unused)) = "The olsr.org Optimized
 int
 main(int argc, char *argv[])
 {
+
+  /* Some cookies for stats keeping */
+  static struct olsr_cookie_info *pulse_timer_cookie = NULL;
+
   struct if_config_options default_ifcnf;
   char conf_file_name[FILENAME_MAX];
   struct ipaddr_str buf;
@@ -320,8 +324,9 @@ main(int argc, char *argv[])
 
 #if !defined WINCE
   if (olsr_cnf->debug_level > 0 && isatty(STDOUT_FILENO)) {
+    pulse_timer_cookie = olsr_alloc_cookie("Pulse", OLSR_COOKIE_TYPE_TIMER);
     olsr_start_timer(STDOUT_PULSE_INT, 0, OLSR_TIMER_PERIODIC,
-                     &generate_stdout_pulse, NULL, 0);
+                     &generate_stdout_pulse, NULL, pulse_timer_cookie->ci_id);
   }
 #endif
 
index 9ba0386..4bb9aee 100644 (file)
@@ -239,6 +239,9 @@ olsr_trigger_forced_update(void *unused __attribute__((unused))) {
 void
 olsr_init_tables(void)
 {  
+  /* Some cookies for stats keeping */
+  static struct olsr_cookie_info *periodic_spf_timer_cookie = NULL;
+
   changes_topology = OLSR_FALSE;
   changes_neighborhood = OLSR_FALSE;
   changes_hna = OLSR_FALSE;
@@ -286,8 +289,11 @@ olsr_init_tables(void)
   
   /* Start periodic SPF and RIB recalculation */
   if (olsr_cnf->lq_dinter > 0.0) {
+    periodic_spf_timer_cookie = olsr_alloc_cookie("Periodic SPF",
+                                                  OLSR_COOKIE_TYPE_TIMER);
     olsr_start_timer((unsigned int)(olsr_cnf->lq_dinter * MSEC_PER_SEC), 5,
-                     OLSR_TIMER_PERIODIC, &olsr_trigger_forced_update, NULL, 0);
+                     OLSR_TIMER_PERIODIC, &olsr_trigger_forced_update, NULL,
+                     periodic_spf_timer_cookie->ci_id);
   }
 }
 
@@ -461,13 +467,19 @@ set_buffer_timer(struct interface *ifn)
 void
 olsr_init_willingness(void)
 {
+  /* Some cookies for stats keeping */
+  static struct olsr_cookie_info *willingness_timer_cookie = NULL;
+
   if (olsr_cnf->willingness_auto) {
 
     /* Run it first and then periodic. */
     olsr_update_willingness(NULL);
 
+    willingness_timer_cookie = olsr_alloc_cookie("Update Willingness",
+                                                 OLSR_COOKIE_TYPE_TIMER);
     olsr_start_timer((unsigned int)olsr_cnf->will_int * MSEC_PER_SEC, 5,
-                     OLSR_TIMER_PERIODIC, &olsr_update_willingness, NULL, 0);
+                     OLSR_TIMER_PERIODIC, &olsr_update_willingness, NULL,
+                     willingness_timer_cookie->ci_id);
   }
 }
 
index ca204fd..e285ec5 100644 (file)
@@ -62,7 +62,7 @@
 #include "hna_set.h"
 #include "common/list.h"
 #include "common/avl.h"
- #include "olsr_spf.h"
+#include "olsr_spf.h"
 #include "net_olsr.h"
 #include "lq_plugin.h"
 
@@ -334,8 +334,9 @@ olsr_calculate_routing_table (void)
   /* We are done if our backoff timer is running */
   if (!spf_backoff_timer) {
     spf_backoff_timer = 
-      olsr_start_timer(1000, 5, OLSR_TIMER_ONESHOT, &olsr_expire_spf_backoff,
-                       NULL, 0);
+      olsr_start_timer(OLSR_SPF_BACKOFF_TIME, OLSR_SPF_BACKOFF_JITTER,
+                       OLSR_TIMER_ONESHOT, &olsr_expire_spf_backoff,
+                       NULL, spf_backoff_timer_cookie->ci_id);
   } else {
     return;
   }
index a496ac6..e9da2c0 100644 (file)
@@ -41,6 +41,9 @@
 #ifndef _OLSR_SPF_H
 #define _OLSR_SPF_H
 
+#define OLSR_SPF_BACKOFF_TIME  (1*1000) /* milliseconds */
+#define OLSR_SPF_BACKOFF_JITTER 5       /* percent */
+
 void olsr_calculate_routing_table(void);
 
 #endif
index 8c878c2..0f0015c 100644 (file)
@@ -56,6 +56,7 @@ static struct olsr_cookie_info *tc_edge_gc_timer_cookie = NULL;
 static struct olsr_cookie_info *tc_validity_timer_cookie = NULL;
 static struct olsr_cookie_info *tc_edge_mem_cookie = NULL;
 struct olsr_cookie_info *tc_mem_cookie = NULL;
+struct olsr_cookie_info *spf_backoff_timer_cookie = NULL;
 
 /*
  * Sven-Ola 2007-Dec: These four constants include an assumption
@@ -189,6 +190,8 @@ olsr_init_tc(void)
     olsr_alloc_cookie("TC edge GC", OLSR_COOKIE_TYPE_TIMER);
   tc_validity_timer_cookie =
     olsr_alloc_cookie("TC validity", OLSR_COOKIE_TYPE_TIMER);
+  spf_backoff_timer_cookie =
+    olsr_alloc_cookie("SPF backoff", OLSR_COOKIE_TYPE_TIMER);
 
   tc_edge_mem_cookie =
     olsr_alloc_cookie("tc_edge_entry", OLSR_COOKIE_TYPE_MEMORY);
index 9ed8c49..9106873 100644 (file)
@@ -144,6 +144,7 @@ LISTNODE2STRUCT(pathlist2tc, struct tc_entry, path_list_node);
 extern struct avl_tree tc_tree;
 extern struct tc_entry *tc_myself;
 extern struct olsr_cookie_info *tc_mem_cookie;
+extern struct olsr_cookie_info *spf_backoff_timer_cookie;
 
 void olsr_init_tc(void);
 void olsr_change_myself_tc(void);