aboutsummaryrefslogtreecommitdiff
path: root/src/or/geoip.c
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 /src/or/geoip.c
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.
Diffstat (limited to 'src/or/geoip.c')
-rw-r--r--src/or/geoip.c6
1 files changed, 5 insertions, 1 deletions
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(