aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-12-24 02:45:46 +0000
committerNick Mathewson <nickm@torproject.org>2006-12-24 02:45:46 +0000
commitbba5a3533f1413601c04a8f61ab0662b77fe7e2b (patch)
tree906f5a9e23837b5b7f718d20415802aa8b90494a /src
parenta9dc42e3815ff49f469d37039df83fb2db6fa73e (diff)
downloadtor-bba5a3533f1413601c04a8f61ab0662b77fe7e2b.tar
tor-bba5a3533f1413601c04a8f61ab0662b77fe7e2b.tar.gz
r11679@Kushana: nickm | 2006-12-23 21:38:41 -0500
Update the state file less often when AvoidDiskWrites is set. svn:r9174
Diffstat (limited to 'src')
-rw-r--r--src/or/circuitbuild.c7
-rw-r--r--src/or/hibernate.c12
-rw-r--r--src/or/rephist.c10
-rw-r--r--src/or/router.c4
4 files changed, 23 insertions, 10 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 5de96f670..38135fb47 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -2412,10 +2412,12 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg)
static void
entry_guards_changed(void)
{
+ time_t when;
entry_guards_dirty = 1;
/* or_state_save() will call entry_guards_update_state(). */
- or_state_mark_dirty(get_or_state(), time(NULL)+600);
+ when = get_options()->AvoidDiskWrites ? time(NULL) + 3600 : time(NULL)+600;
+ or_state_mark_dirty(get_or_state(), when);
}
/** If the entry guard info has not changed, do nothing and return.
@@ -2466,7 +2468,8 @@ entry_guards_update_state(or_state_t *state)
next = &(line->next);
}
});
- or_state_mark_dirty(get_or_state(), 0);
+ if (!get_options()->AvoidDiskWrites)
+ or_state_mark_dirty(get_or_state(), 0);
entry_guards_dirty = 0;
}
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index 2be95cb3c..65ad4c80f 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -581,7 +581,9 @@ accounting_record_bandwidth_usage(time_t now, or_state_t *state)
ROUND_UP(n_bytes_written_in_interval);
state->AccountingSecondsActive = n_seconds_active_in_interval;
state->AccountingExpectedUsage = expected_bandwidth_usage;
- or_state_mark_dirty(state, now+60);
+
+ or_state_mark_dirty(state,
+ now+(get_options()->AvoidDiskWrites ? 7200 : 60));
return r;
}
@@ -767,7 +769,9 @@ 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);
+
+ or_state_mark_dirty(get_or_state(),
+ get_options()->AvoidDiskWrites ? now+600 : 0);
}
/** Called when we've been hibernating and our timeout is reached. */
@@ -835,7 +839,9 @@ hibernate_go_dormant(time_t now)
}
accounting_record_bandwidth_usage(now, get_or_state());
- or_state_mark_dirty(get_or_state(), 0);
+
+ or_state_mark_dirty(get_or_state(),
+ get_options()->AvoidDiskWrites ? now+600 : 0);
}
/** Called when hibernate_end_time has arrived. */
diff --git a/src/or/rephist.c b/src/or/rephist.c
index c30583fe5..7b13d124b 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -669,8 +669,11 @@ rep_hist_update_state(or_state_t *state)
* force these values to the defaults. */
/* FFFF we should pull the default out of config.c's state table,
* so we don't have two defaults. */
- if (*s_begins != 0 || *s_interval != 900)
- or_state_mark_dirty(get_or_state(), time(NULL)+600);
+ if (*s_begins != 0 || *s_interval != 900) {
+ time_t now = time(NULL);
+ time_t save_at = get_options()->AvoidDiskWrites ? now+3600 : now+600;
+ or_state_mark_dirty(state, save_at);
+ }
*s_begins = 0;
*s_interval = 900;
*s_values = smartlist_create();
@@ -687,8 +690,9 @@ rep_hist_update_state(or_state_t *state)
smartlist_split_string(*s_values, buf, ",", SPLIT_SKIP_SPACE, 0);
}
tor_free(buf);
- if (server_mode(get_options()))
+ if (server_mode(get_options())) {
or_state_mark_dirty(get_or_state(), time(NULL)+(2*3600));
+ }
}
/** Set bandwidth history from our saved state. */
diff --git a/src/or/router.c b/src/or/router.c
index a69cd180e..a43584205 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -156,7 +156,7 @@ rotate_onion_key(void)
state->LastRotatedOnionKey = onionkey_set_at = now;
tor_mutex_release(key_lock);
mark_my_descriptor_dirty();
- or_state_mark_dirty(state, 0);
+ or_state_mark_dirty(state, get_options()->AvoidDiskWrites ? now+3600 : 0);
return;
error:
log_warn(LD_GENERAL, "Couldn't rotate onion key.");
@@ -308,7 +308,7 @@ init_keys(void)
* start the clock ticking now so that we will eventually rotate it even
* if we don't stay up for a full MIN_ONION_KEY_LIFETIME. */
state->LastRotatedOnionKey = time(NULL);
- or_state_mark_dirty(state, 0);
+ or_state_mark_dirty(state, options->AvoidDiskWrites ? time(NULL)+3600 : 0);
}
tor_snprintf(keydir,sizeof(keydir),"%s/keys/secret_onion_key.old",datadir);