summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarsten Loesing <karsten.loesing@gmx.net>2009-08-14 14:33:29 +0200
committerKarsten Loesing <karsten.loesing@gmx.net>2009-08-14 14:56:38 +0200
commit9d16a59fccd997b266b5cacde2acfd691002bf7a (patch)
tree3bbdfa3779f23f816773bc915f00cea00226568e
parente0dc2e907eb029bd4e3d7933ef72f3ff942a9b81 (diff)
downloadtor-9d16a59fccd997b266b5cacde2acfd691002bf7a.tar.gz
tor-9d16a59fccd997b266b5cacde2acfd691002bf7a.zip
Remove ./configure option for exit port statistics.
-rw-r--r--configure.in7
-rw-r--r--src/or/config.c6
-rw-r--r--src/or/or.h6
-rw-r--r--src/or/rephist.c27
4 files changed, 22 insertions, 24 deletions
diff --git a/configure.in b/configure.in
index ab7d6480cf..7a8764ce91 100644
--- a/configure.in
+++ b/configure.in
@@ -85,13 +85,6 @@ case $host in
;;
esac
-AC_ARG_ENABLE(exit-stats,
- AS_HELP_STRING(--enable-exit-stats, enable code for exits to collect per-port statistics))
-
-if test "$enable_exit_stats" = "yes"; then
- AC_DEFINE(ENABLE_EXIT_STATS, 1, [Defined if we try to collect per-port statistics on exits])
-fi
-
AC_ARG_ENABLE(dirreq-stats,
AS_HELP_STRING(--enable-dirreq-stats, enable code for directories to collect per-country statistics))
diff --git a/src/or/config.c b/src/or/config.c
index 0b580876fb..6d34008386 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1426,16 +1426,10 @@ options_act(or_options_t *old_options)
#endif
}
-#ifdef ENABLE_EXIT_STATS
if (options->ExitPortStatistics)
log_notice(LD_CONFIG, "Configured to measure exit port statistics. "
"Look for the exit-stats file that will first be written to "
"the data directory in 24 hours from now.");
-#else
- if (options->ExitPortStatistics)
- log_warn(LD_CONFIG, "ExitPortStatistics enabled, but Tor was built "
- "without port statistics support.");
-#endif
#ifdef ENABLE_BUFFER_STATS
if (options->CellStatistics)
diff --git a/src/or/or.h b/src/or/or.h
index 253e89af85..4db824afea 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -4072,17 +4072,11 @@ void rep_hist_note_extend_failed(const char *from_name, const char *to_name);
void rep_hist_dump_stats(time_t now, int severity);
void rep_hist_note_bytes_read(size_t num_bytes, time_t when);
void rep_hist_note_bytes_written(size_t num_bytes, time_t when);
-#ifdef ENABLE_EXIT_STATS
void rep_hist_note_exit_bytes_read(uint16_t port, size_t num_bytes,
time_t now);
void rep_hist_note_exit_bytes_written(uint16_t port, size_t num_bytes,
time_t now);
void rep_hist_note_exit_stream_opened(uint16_t port, time_t now);
-#else
-#define rep_hist_note_exit_bytes_read(p,n,t) STMT_NIL
-#define rep_hist_note_exit_bytes_written(p,n,t) STMT_NIL
-#define rep_hist_note_exit_stream_opened(p,t) STMT_NIL
-#endif
int rep_hist_bandwidth_assess(void);
char *rep_hist_get_bandwidth_lines(int for_extrainfo);
void rep_hist_update_state(or_state_t *state);
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();
}