summaryrefslogtreecommitdiff
path: root/src/or/hibernate.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-12-24 03:06:03 +0000
committerNick Mathewson <nickm@torproject.org>2006-12-24 03:06:03 +0000
commitbf1014692f9aea062f10df525ba39115ef890776 (patch)
tree6e0f7f8bfa5d396e9d4cd5584116deeafb10a4a5 /src/or/hibernate.c
parentf3fd5d9032e377783a90b9b6995ef3a6413fc98e (diff)
downloadtor-bf1014692f9aea062f10df525ba39115ef890776.tar.gz
tor-bf1014692f9aea062f10df525ba39115ef890776.zip
r11686@Kushana: nickm | 2006-12-23 22:05:57 -0500
More changes wrt unnecessary disk writes. svn:r9176
Diffstat (limited to 'src/or/hibernate.c')
-rw-r--r--src/or/hibernate.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index 65ad4c80f3..d7968f721a 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -544,6 +544,7 @@ accounting_record_bandwidth_usage(time_t now, or_state_t *state)
time_t tmp;
int r;
uint64_t expected;
+ static time_t last_recorded;
/* First, update bw_accounting. Until 0.1.2.5-x, this was the only place
* we stored this information. The format is:
@@ -572,7 +573,10 @@ accounting_record_bandwidth_usage(time_t now, or_state_t *state)
(unsigned long)expected);
tor_snprintf(fname, sizeof(fname), "%s/bw_accounting",
get_options()->DataDirectory);
- r = write_str_to_file(fname, buf, 0);
+ if (!get_options()->AvoidDiskWrites || (last_recorded + 3600 < now)) {
+ r = write_str_to_file(fname, buf, 0);
+ last_recorded = now;
+ }
/* Now update the state */
state->AccountingIntervalStart = interval_start_time;