Remove ./configure option for exit port statistics.

This commit is contained in:
Karsten Loesing
2009-08-14 14:33:29 +02:00
parent e0dc2e907e
commit 9d16a59fcc
4 changed files with 22 additions and 24 deletions
-7
View File
@@ -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))
-6
View File
@@ -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)
-6
View File
@@ -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);
+22 -5
View File
@@ -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();
}