[tor-commits] [tor/master] relays checkpoint their state file twice a day
nickm at torproject.org
nickm at torproject.org
Fri Apr 29 03:30:51 UTC 2011
commit 66de6f7eb8e2948f6c3849dbca20c7b31969b5b7
Author: Roger Dingledine <arma at torproject.org>
Date: Thu Apr 28 21:06:25 2011 -0400
relays checkpoint their state file twice a day
---
changes/bug3012 | 5 +++++
src/or/config.c | 11 ++++++++++-
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/changes/bug3012 b/changes/bug3012
new file mode 100644
index 0000000..dfde5fa
--- /dev/null
+++ b/changes/bug3012
@@ -0,0 +1,5 @@
+ o Minor features:
+ - Relays can go for weeks without writing out their state file. A
+ relay that crashes would lose its bandwidth history (including
+ capacity estimate), client country statistics, and so on. Now relays
+ checkpoint the file at least every 12 hours. Addresses bug 3012.
diff --git a/src/or/config.c b/src/or/config.c
index 9384b3a..dc24140 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -5122,6 +5122,11 @@ or_state_load(void)
/** If writing the state to disk fails, try again after this many seconds. */
#define STATE_WRITE_RETRY_INTERVAL 3600
+/** If we're a relay, how often should we checkpoint our state file even
+ * if nothing else dirties it? This will checkpoint ongoing stats like
+ * bandwidth used, per-country user stats, etc. */
+#define STATE_RELAY_CHECKPOINT_INTERVAL (12*60*60)
+
/** Write the persistent state to disk. Return 0 for success, <0 on failure. */
int
or_state_save(time_t now)
@@ -5172,7 +5177,11 @@ or_state_save(time_t now)
tor_free(fname);
tor_free(contents);
- global_state->next_write = TIME_MAX;
+ if (server_mode(get_options()))
+ global_state->next_write = now + STATE_RELAY_CHECKPOINT_INTERVAL;
+ else
+ global_state->next_write = TIME_MAX;
+
return 0;
}
More information about the tor-commits
mailing list