Переглянути джерело

add a trivial tor-counting variable

svn:r4593
Roger Dingledine 19 роки тому
батько
коміт
e8a1b1d6a0
2 змінених файлів з 7 додано та 3 видалено
  1. 3 2
      src/or/main.c
  2. 4 1
      src/or/rephist.c

+ 3 - 2
src/or/main.c

@@ -1132,12 +1132,13 @@ dumpmemusage(int severity)
   extern uint64_t buf_total_used;
   extern uint64_t buf_total_alloc;
   extern uint64_t rephist_total_alloc;
+  extern uint32_t rephist_total_num;
 
   log(severity, "In buffers: "U64_FORMAT" used/"U64_FORMAT" allocated (%d conns).",
       U64_PRINTF_ARG(buf_total_used), U64_PRINTF_ARG(buf_total_alloc),
       nfds);
-  log(severity, "In rephist: "U64_FORMAT" used.",
-      U64_PRINTF_ARG(rephist_total_alloc));
+  log(severity, "In rephist: "U64_FORMAT" used by %d Tors.",
+      U64_PRINTF_ARG(rephist_total_alloc), rephist_total_num);
 }
 
 /** Write all statistics to the log, with log level 'severity'.  Called

+ 4 - 1
src/or/rephist.c

@@ -15,7 +15,8 @@ const char rephist_c_id[] = "$Id$";
 static void bw_arrays_init(void);
 static void predicted_ports_init(void);
 
-uint64_t rephist_total_alloc;
+uint64_t rephist_total_alloc=0;
+uint32_t rephist_total_num=0;
 
 /** History of an OR-\>OR link. */
 typedef struct link_history_t {
@@ -73,6 +74,7 @@ get_or_history(const char* id)
   if (!hist) {
     hist = tor_malloc_zero(sizeof(or_history_t));
     rephist_total_alloc += sizeof(or_history_t);
+    rephist_total_num++;
     hist->link_history_map = strmap_new();
     hist->since = hist->changed = time(NULL);
     strmap_set(history_map, hexid, hist);
@@ -121,6 +123,7 @@ free_or_history(void *_hist)
   or_history_t *hist = _hist;
   strmap_free(hist->link_history_map, _free_link_history);
   rephist_total_alloc -= sizeof(or_history_t);
+  rephist_total_num--;
   tor_free(hist);
 }