Browse Source

[pim] Cosmetic RPF refresh timer display

Everton Marques 9 years ago
parent
commit
ff752d4316
3 changed files with 10 additions and 1 deletions
  1. 1 1
      pimd/pim_cmd.c
  2. 8 0
      pimd/pim_time.c
  3. 1 0
      pimd/pim_time.h

+ 1 - 1
pimd/pim_cmd.c

@@ -1081,7 +1081,7 @@ static void show_rpf_refresh_stats(struct vty *vty, time_t now)
 {
   char refresh_uptime[10];
 
-  pim_time_uptime(refresh_uptime, sizeof(refresh_uptime), now - qpim_rpf_cache_refresh_last);
+  pim_time_uptime_begin(refresh_uptime, sizeof(refresh_uptime), now, qpim_rpf_cache_refresh_last);
 
   vty_out(vty, 
 	  "RPF Cache Refresh Delay:    %ld msecs%s"

+ 8 - 0
pimd/pim_time.c

@@ -190,6 +190,14 @@ void pim_time_uptime(char *buf, int buf_size, int64_t uptime_sec)
   pim_time_hhmmss(buf, buf_size, uptime_sec);
 }
 
+void pim_time_uptime_begin(char *buf, int buf_size, int64_t now, int64_t begin)
+{
+  if (begin > 0)
+    pim_time_uptime(buf, buf_size, now - begin);
+  else
+    snprintf(buf, buf_size, "--:--:--");
+}
+
 long pim_time_timer_remain_msec(struct thread *t_timer)
 {
   /* FIXME: Actually fetch msec resolution from thread */

+ 1 - 0
pimd/pim_time.h

@@ -34,6 +34,7 @@ int pim_time_mmss(char *buf, int buf_size, long sec);
 void pim_time_timer_to_mmss(char *buf, int buf_size, struct thread *t);
 void pim_time_timer_to_hhmmss(char *buf, int buf_size, struct thread *t);
 void pim_time_uptime(char *buf, int buf_size, int64_t uptime_sec);
+void pim_time_uptime_begin(char *buf, int buf_size, int64_t now, int64_t begin);
 long pim_time_timer_remain_msec(struct thread *t_timer);
 
 #endif /* PIM_TIME_H */