summaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-01-10 16:44:42 -0500
committerNick Mathewson <nickm@torproject.org>2011-01-10 16:51:11 -0500
commit95968a625e91ae43aef9a4b810f93078dabe1419 (patch)
tree3626b90193b9c364bac21aa7de2f88c411282891 /src/or/config.c
parent5ae391762c93fa4cdf47ceb24c31282daf695a65 (diff)
downloadtor-95968a625e91ae43aef9a4b810f93078dabe1419.tar.gz
tor-95968a625e91ae43aef9a4b810f93078dabe1419.zip
Wait 60 minutes before retrying failed state save; bug2346
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 17d776e71e..5198eaa055 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -5145,6 +5145,9 @@ or_state_load(void)
return r;
}
+/** If writing the state to disk fails, try again after this many seconds. */
+#define STATE_WRITE_RETRY_INTERVAL 3600
+
/** Write the persistent state to disk. Return 0 for success, <0 on failure. */
int
or_state_save(time_t now)
@@ -5179,10 +5182,13 @@ or_state_save(time_t now)
tor_free(state);
fname = get_datadir_fname("state");
if (write_str_to_file(fname, contents, 0)<0) {
- log_warn(LD_FS, "Unable to write state to file \"%s\"", fname);
+ log_warn(LD_FS, "Unable to write state to file \"%s\"; will try later",
+ fname);
global_state->LastWritten = -1;
tor_free(fname);
tor_free(contents);
+ /* Try again in after STATE_WRITE_RETRY_INTERVAL */
+ global_state->next_write = now + STATE_WRITE_RETRY_INTERVAL;
return -1;
}