do not restart a periodic timer if the callback function has stopped the timer
authorHannes Gredler <hannes@gredler.at>
Wed, 5 Mar 2008 08:33:45 +0000 (09:33 +0100)
committerHannes Gredler <hannes@gredler.at>
Wed, 5 Mar 2008 08:33:45 +0000 (09:33 +0100)
src/scheduler.c

index 75c417a..b683c8c 100644 (file)
@@ -370,15 +370,24 @@ olsr_walk_timers(clock_t *last_run)
 
         if (timer->timer_period) {
 
-          /* For periodical timers, rehash the random number and restart */
-          timer->timer_random = random();
-          olsr_change_timer(timer, timer->timer_period, timer->timer_jitter_pct,
-                            OLSR_TIMER_PERIODIC);
+          /*
+           * Don't restart the periodic timer if the callback function has
+           * stopped the timer.
+           */
+          if (timer->timer_flags & OLSR_TIMER_RUNNING) {
+
+            /* For periodical timers, rehash the random number and restart */
+            timer->timer_random = random();
+            olsr_change_timer(timer, timer->timer_period,
+                              timer->timer_jitter_pct,
+                              OLSR_TIMER_PERIODIC);
+          }
+
         } else {
 
           /*
-           * Don't stop the timer if the callback function already has stopped
-           * the timer.
+           * Don't stop the singleshot timer if the callback function has
+           * stopped the timer.
            */
           if (timer->timer_flags & OLSR_TIMER_RUNNING) {