diff options
author | Karsten Loesing <karsten.loesing@gmx.net> | 2009-08-14 14:33:29 +0200 |
---|---|---|
committer | Karsten Loesing <karsten.loesing@gmx.net> | 2009-08-14 14:56:38 +0200 |
commit | 9d16a59fccd997b266b5cacde2acfd691002bf7a (patch) | |
tree | 3bbdfa3779f23f816773bc915f00cea00226568e /src/or/rephist.c | |
parent | e0dc2e907eb029bd4e3d7933ef72f3ff942a9b81 (diff) | |
download | tor-9d16a59fccd997b266b5cacde2acfd691002bf7a.tar.gz tor-9d16a59fccd997b266b5cacde2acfd691002bf7a.zip |
Remove ./configure option for exit port statistics.
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r-- | src/or/rephist.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c index c0b9ae14a4..0d370a3b11 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -1320,7 +1320,6 @@ rep_hist_note_bytes_read(size_t num_bytes, time_t when) add_obs(read_array, when, num_bytes); } -#ifdef ENABLE_EXIT_STATS /* Some constants */ /** How long are the intervals for measuring exit stats? */ #define EXIT_STATS_INTERVAL_SEC (24 * 60 * 60) @@ -1339,11 +1338,23 @@ rep_hist_note_bytes_read(size_t num_bytes, time_t when) * the price of some memory (1.25 MB) and linear complexity when writing * stats. */ /** Number of bytes read in current period by exit port */ -static uint64_t exit_bytes_read[EXIT_STATS_NUM_PORTS]; +static uint64_t *exit_bytes_read = NULL; /** Number of bytes written in current period by exit port */ -static uint64_t exit_bytes_written[EXIT_STATS_NUM_PORTS]; +static uint64_t *exit_bytes_written = NULL; /** Number of streams opened in current period by exit port */ -static uint32_t exit_streams[EXIT_STATS_NUM_PORTS]; +static uint32_t *exit_streams = NULL; + +/** Set up arrays for exit port statistics. */ +static void +exit_stats_init(void) +{ + exit_bytes_read = tor_malloc_zero(EXIT_STATS_NUM_PORTS * + sizeof(uint64_t)); + exit_bytes_written = tor_malloc_zero(EXIT_STATS_NUM_PORTS * + sizeof(uint64_t)); + exit_streams = tor_malloc_zero(EXIT_STATS_NUM_PORTS * + sizeof(uint32_t)); +} /** When does the current exit stats period end? */ static time_t end_of_current_exit_stats_period = 0; @@ -1362,6 +1373,8 @@ write_exit_stats(time_t when) FILE *out = NULL; log_debug(LD_HIST, "Considering writing exit port statistics to disk.."); + if (!exit_bytes_read) + exit_stats_init(); while (when > end_of_current_exit_stats_period) { format_iso_time(t, end_of_current_exit_stats_period); log_info(LD_HIST, "Writing exit port statistics to disk for period " @@ -1466,6 +1479,8 @@ write_exit_stats(time_t when) static void add_exit_obs(time_t when) { + if (!exit_bytes_read) + exit_stats_init(); if (when > end_of_current_exit_stats_period) { if (end_of_current_exit_stats_period) write_exit_stats(when); @@ -1513,7 +1528,6 @@ rep_hist_note_exit_stream_opened(uint16_t port, time_t when) exit_streams[port]++; log_debug(LD_HIST, "Opened exit stream to port %d", port); } -#endif /** Helper: Return the largest value in b->maxima. (This is equal to the * most bandwidth used in any NUM_SECS_ROLLING_MEASURE period for the last @@ -2049,6 +2063,9 @@ rep_hist_free_all(void) tor_free(read_array); tor_free(write_array); tor_free(last_stability_doc); + tor_free(exit_bytes_read); + tor_free(exit_bytes_written); + tor_free(exit_streams); built_last_stability_doc_at = 0; predicted_ports_free(); } |