add a trivial tor-counting variable

svn:r4593
This commit is contained in:
Roger Dingledine 2005-07-18 06:09:04 +00:00
parent e573b3f7db
commit e8a1b1d6a0
2 changed files with 7 additions and 3 deletions

View File

@ -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

View File

@ -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);
}