summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarsten Loesing <karsten.loesing@gmx.net>2009-09-24 21:58:56 +0200
committerKarsten Loesing <karsten.loesing@gmx.net>2009-09-24 21:58:56 +0200
commit457bebe01a0cffc7b2603e87611f0e5820f1cca4 (patch)
tree28bf44a9765c75686120c774a4531b0bcdf6fe6f
parent52fa4f6428388be34f78951ed0a140b01a44a86c (diff)
downloadtor-457bebe01a0cffc7b2603e87611f0e5820f1cca4.tar.gz
tor-457bebe01a0cffc7b2603e87611f0e5820f1cca4.zip
Fix a couple of smaller issues with gathering statistics.
- Avoid memmoving 0 bytes which might lead to compiler warnings. - Don't require relays to be entry node AND bridge at the same to time to record clients. - Fix a memory leak when writing dirreq-stats. - Don't say in the stats files that measurement intervals are twice as long as they really are. - Reduce minimum observation time for requests to 12 hours, or we might never record usage. - Clear exit stats correctly after writing them, or we accumulate old stats over time. - Reset interval start for buffer stats, too.
-rw-r--r--ChangeLog3
-rw-r--r--src/or/geoip.c6
-rw-r--r--src/or/main.c2
-rw-r--r--src/or/or.h2
-rw-r--r--src/or/rephist.c7
5 files changed, 14 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 8f36d6773d..cc729c3658 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,9 @@ Changes in version 0.2.2.4-alpha - 2009-??-??
code, and so on. The unit test code has moved to its own
subdirectory, and has been split into multiple modules.
+ o Minor bugfixes:
+ - Fix a couple of smaller issues with gathering statistics. Bugfixes
+ on 0.2.2.1-alpha.
Changes in version 0.2.2.3-alpha - 2009-09-23
o Major bugfixes:
diff --git a/src/or/geoip.c b/src/or/geoip.c
index 00e608214c..5b40c2e058 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -370,10 +370,12 @@ static void
rotate_request_period(void)
{
SMARTLIST_FOREACH(geoip_countries, geoip_country_t *, c, {
+#if REQUEST_HIST_LEN > 1
memmove(&c->n_v2_ns_requests[0], &c->n_v2_ns_requests[1],
sizeof(uint32_t)*(REQUEST_HIST_LEN-1));
memmove(&c->n_v3_ns_requests[0], &c->n_v3_ns_requests[1],
sizeof(uint32_t)*(REQUEST_HIST_LEN-1));
+#endif
c->n_v2_ns_requests[REQUEST_HIST_LEN-1] = 0;
c->n_v3_ns_requests[REQUEST_HIST_LEN-1] = 0;
});
@@ -393,7 +395,7 @@ geoip_note_client_seen(geoip_client_action_t action,
clientmap_entry_t lookup, *ent;
if (action == GEOIP_CLIENT_CONNECT) {
/* Only remember statistics as entry guard or as bridge. */
- if (!options->EntryStatistics ||
+ if (!options->EntryStatistics &&
(!(options->BridgeRelay && options->BridgeRecordUsageByCountry)))
return;
/* Did we recently switch from bridge to relay or back? */
@@ -1009,6 +1011,8 @@ geoip_dirreq_stats_write(time_t now)
if (fprintf(out, "dirreq-v3-reqs %s\ndirreq-v2-reqs %s\n",
data_v3 ? data_v3 : "", data_v2 ? data_v2 : "") < 0)
goto done;
+ tor_free(data_v2);
+ tor_free(data_v3);
#define RESPONSE_GRANULARITY 8
for (i = 0; i < GEOIP_NS_RESPONSE_NUM; i++) {
ns_v2_responses[i] = round_uint32_to_next_multiple_of(
diff --git a/src/or/main.c b/src/or/main.c
index c33d1b39b4..25182919ae 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -981,7 +981,6 @@ run_scheduled_events(time_t now)
time_to_write_stats_files = now + WRITE_STATS_INTERVAL;
} else {
/* Write stats to disk. */
- time_to_write_stats_files += WRITE_STATS_INTERVAL;
if (options->CellStatistics)
rep_hist_buffer_stats_write(time_to_write_stats_files);
if (options->DirReqStatistics)
@@ -990,6 +989,7 @@ run_scheduled_events(time_t now)
geoip_entry_stats_write(time_to_write_stats_files);
if (options->ExitPortStatistics)
rep_hist_exit_stats_write(time_to_write_stats_files);
+ time_to_write_stats_files += WRITE_STATS_INTERVAL;
}
} else {
/* Never write stats to disk */
diff --git a/src/or/or.h b/src/or/or.h
index a7db06f71d..0162e31f01 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3867,7 +3867,7 @@ int dnsserv_launch_request(const char *name, int is_reverse);
#define DIR_ENTRY_RECORD_USAGE_RETAIN_IPS (24*60*60)
/** How long do we have to have observed per-country request history before
* we are willing to talk about it? */
-#define DIR_RECORD_USAGE_MIN_OBSERVATION_TIME (24*60*60)
+#define DIR_RECORD_USAGE_MIN_OBSERVATION_TIME (12*60*60)
#ifdef GEOIP_PRIVATE
int geoip_parse_entry(const char *line);
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 8d78ac26c3..1ff9cde69f 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -1461,9 +1461,9 @@ rep_hist_exit_stats_write(time_t now)
comma ? "," : "", other_streams)<0)
goto done;
/* Reset counters */
- memset(exit_bytes_read, 0, sizeof(exit_bytes_read));
- memset(exit_bytes_written, 0, sizeof(exit_bytes_written));
- memset(exit_streams, 0, sizeof(exit_streams));
+ memset(exit_bytes_read, 0, EXIT_STATS_NUM_PORTS * sizeof(uint64_t));
+ memset(exit_bytes_written, 0, EXIT_STATS_NUM_PORTS * sizeof(uint64_t));
+ memset(exit_streams, 0, EXIT_STATS_NUM_PORTS * sizeof(uint32_t));
start_of_exit_stats_interval = now;
if (open_file)
@@ -2771,6 +2771,7 @@ rep_hist_buffer_stats_write(time_t now)
goto done;
finish_writing_to_file(open_file);
open_file = NULL;
+ start_of_buffer_stats_interval = now;
done:
if (open_file)
abort_writing_to_file(open_file);