mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
r11679@Kushana: nickm | 2006-12-23 21:38:41 -0500
Update the state file less often when AvoidDiskWrites is set. svn:r9174
This commit is contained in:
parent
a9dc42e381
commit
bba5a3533f
@ -43,6 +43,7 @@ Changes in version 0.1.2.5-xxxx - 200?-??-??
|
||||
dirserver has given us a 503, we try not to use it until an hour
|
||||
has gone by, or until we have no dirservers that haven't given us
|
||||
a 503.
|
||||
- The state file gets saved less often when AvoidDiskWrites is set.
|
||||
|
||||
o Security bugfixes:
|
||||
- Stop sending the HttpProxyAuthenticator string to directory
|
||||
|
2
doc/TODO
2
doc/TODO
@ -154,7 +154,7 @@ Nd- Have a mode that doesn't write to disk much, so we can run Tor on
|
||||
flash memory (e.g. Linksys routers or USB keys).
|
||||
o Add AvoidDiskWrites config option.
|
||||
. only write state file when it's "changed"
|
||||
- crank up the numbers if avoiddiskwrites is on.
|
||||
o crank up the numbers if avoiddiskwrites is on.
|
||||
- some things may not want to get written at all.
|
||||
- stop writing identity key / fingerprint / etc every restart
|
||||
- more?
|
||||
|
@ -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,6 +2468,7 @@ entry_guards_update_state(or_state_t *state)
|
||||
next = &(line->next);
|
||||
}
|
||||
});
|
||||
if (!get_options()->AvoidDiskWrites)
|
||||
or_state_mark_dirty(get_or_state(), 0);
|
||||
entry_guards_dirty = 0;
|
||||
}
|
||||
|
@ -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. */
|
||||
|
@ -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,9 +690,10 @@ 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. */
|
||||
int
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user