aboutsummaryrefslogtreecommitdiff
path: root/src/or/rephist.c
diff options
context:
space:
mode:
authorKarsten Loesing <karsten.loesing@gmx.net>2009-08-21 23:02:36 +0200
committerKarsten Loesing <karsten.loesing@gmx.net>2009-08-21 23:02:36 +0200
commit8c29b7920ae18a46ce0527806507275783d1ae42 (patch)
tree0ff5936969a5b1b831686d1af5fbcff968dd915f /src/or/rephist.c
parent75c59d1a92e0f4956bd249844c188c432aae1712 (diff)
downloadtor-8c29b7920ae18a46ce0527806507275783d1ae42.tar.gz
tor-8c29b7920ae18a46ce0527806507275783d1ae42.zip
Add some fixes after discussion with Nick.
- Refactor geoip.c by moving duplicate code into rotate_request_period(). - Don't leak memory when cleaning up cell queues. - Make sure that exit_(streams|bytes_(read|written)) are initialized in all places accessing these arrays. - Read only the last block from *stats files and ensure that its timestamp is not more than 25 hours in the past and not more than 1 hour in the future. - Stop truncating the last character when reading *stats files. The only thing that's left now is to avoid reading whole *stats files into memory.
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r--src/or/rephist.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c
index f7d0b2bbcf..8d78ac26c3 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -1371,6 +1371,9 @@ rep_hist_exit_stats_write(time_t now)
open_file_t *open_file = NULL;
FILE *out = NULL;
+ if (!exit_streams)
+ return; /* Not initialized */
+
statsdir = get_datadir_fname("stats");
if (check_private_dir(statsdir, CPD_CREATE) < 0)
goto done;
@@ -1480,6 +1483,8 @@ rep_hist_note_exit_bytes_written(uint16_t port, size_t num_bytes)
{
if (!get_options()->ExitPortStatistics)
return;
+ if (!exit_bytes_written)
+ return; /* Not initialized */
exit_bytes_written[port] += num_bytes;
log_debug(LD_HIST, "Written %lu bytes to exit connection to port %d.",
(unsigned long)num_bytes, port);
@@ -1492,6 +1497,8 @@ rep_hist_note_exit_bytes_read(uint16_t port, size_t num_bytes)
{
if (!get_options()->ExitPortStatistics)
return;
+ if (!exit_bytes_read)
+ return; /* Not initialized */
exit_bytes_read[port] += num_bytes;
log_debug(LD_HIST, "Read %lu bytes from exit connection to port %d.",
(unsigned long)num_bytes, port);
@@ -1503,6 +1510,8 @@ rep_hist_note_exit_stream_opened(uint16_t port)
{
if (!get_options()->ExitPortStatistics)
return;
+ if (!exit_streams)
+ return; /* Not initialized */
exit_streams[port]++;
log_debug(LD_HIST, "Opened exit stream to port %d", port);
}