aboutsummaryrefslogtreecommitdiff
path: root/src/or/hibernate.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-12-07 20:11:30 +0000
committerNick Mathewson <nickm@torproject.org>2006-12-07 20:11:30 +0000
commit7c79495137bcd3989428d65b184038aa71fbae70 (patch)
treea18217ed1dfeb55a8ba045772364d08837f20fbb /src/or/hibernate.c
parentc304a10fd3ec7943734d47c2e95fcd1b75bf526d (diff)
downloadtor-7c79495137bcd3989428d65b184038aa71fbae70.tar
tor-7c79495137bcd3989428d65b184038aa71fbae70.tar.gz
r11468@Kushana: nickm | 2006-12-07 14:56:57 -0500
Revise logic used to flush state to disk. Now, we try to batch non-urgent changes so that we do not do too many writes, and we save very-non-urgent changes every once in a rare while, and we never save more than once per second. svn:r9047
Diffstat (limited to 'src/or/hibernate.c')
-rw-r--r--src/or/hibernate.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index 79c51c718..bd89240e4 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -391,8 +391,8 @@ reset_accounting(time_t now)
static INLINE int
time_to_record_bandwidth_usage(time_t now)
{
- /* Note every 60 sec */
-#define NOTE_INTERVAL (60)
+ /* Note every 600 sec */
+#define NOTE_INTERVAL (600)
/* Or every 20 megabytes */
#define NOTE_BYTES 20*(1024*1024)
static uint64_t last_read_bytes_noted = 0;
@@ -575,7 +575,7 @@ accounting_record_bandwidth_usage(time_t now, or_state_t *state)
state->AccountingBytesWrittenInInterval = n_bytes_written_in_interval;
state->AccountingSecondsActive = n_seconds_active_in_interval;
state->AccountingExpectedUsage = expected_bandwidth_usage;
- state->dirty = 1;
+ or_state_mark_dirty(state, 60);
return r;
}
@@ -760,6 +760,7 @@ hibernate_begin(int new_state, time_t now)
hibernate_state = new_state;
accounting_record_bandwidth_usage(now, get_or_state());
+ or_state_mark_dirty(get_or_state(), 0);
}
/** Called when we've been hibernating and our timeout is reached. */
@@ -827,6 +828,7 @@ hibernate_go_dormant(time_t now)
}
accounting_record_bandwidth_usage(now, get_or_state());
+ or_state_mark_dirty(get_or_state(), 0);
}
/** Called when hibernate_end_time has arrived. */