Merge remote branch 'origin/maint-0.2.2'

This commit is contained in:
Nick Mathewson 2010-12-06 12:07:37 -05:00
commit 3fc43debfb
2 changed files with 7 additions and 6 deletions

4
changes/bug2146.1 Normal file
View File

@ -0,0 +1,4 @@
- Major bugfixes:
o Fix a bug that could break accounting on 64-bit systems with large
time_t values, making them hibernate for impossibly long intervals.
Bugfix on 0.0.9pre6; fix for bug 2146; fix by boboper.

View File

@ -515,7 +515,6 @@ accounting_run_housekeeping(time_t now)
static void static void
accounting_set_wakeup_time(void) accounting_set_wakeup_time(void)
{ {
char buf[ISO_TIME_LEN+1];
char digest[DIGEST_LEN]; char digest[DIGEST_LEN];
crypto_digest_env_t *d_env; crypto_digest_env_t *d_env;
int time_in_interval; int time_in_interval;
@ -530,6 +529,7 @@ accounting_set_wakeup_time(void)
} }
if (server_identity_key_is_set()) { if (server_identity_key_is_set()) {
char buf[ISO_TIME_LEN+1];
format_iso_time(buf, interval_start_time); format_iso_time(buf, interval_start_time);
crypto_pk_get_digest(get_server_identity_key(), digest); crypto_pk_get_digest(get_server_identity_key(), digest);
@ -548,7 +548,6 @@ accounting_set_wakeup_time(void)
char buf2[ISO_TIME_LEN+1]; char buf2[ISO_TIME_LEN+1];
format_local_iso_time(buf1, interval_start_time); format_local_iso_time(buf1, interval_start_time);
format_local_iso_time(buf2, interval_end_time); format_local_iso_time(buf2, interval_end_time);
time_to_exhaust_bw = GUESS_TIME_TO_USE_BANDWIDTH;
interval_wakeup_time = interval_start_time; interval_wakeup_time = interval_start_time;
log_notice(LD_ACCT, log_notice(LD_ACCT,
@ -563,8 +562,8 @@ accounting_set_wakeup_time(void)
time_to_exhaust_bw = time_to_exhaust_bw =
(get_options()->AccountingMax/expected_bandwidth_usage)*60; (get_options()->AccountingMax/expected_bandwidth_usage)*60;
if (time_to_exhaust_bw > TIME_MAX) { if (time_to_exhaust_bw > INT_MAX) {
time_to_exhaust_bw = TIME_MAX; time_to_exhaust_bw = INT_MAX;
time_to_consider = 0; time_to_consider = 0;
} else { } else {
time_to_consider = time_in_interval - (int)time_to_exhaust_bw; time_to_consider = time_in_interval - (int)time_to_exhaust_bw;
@ -582,8 +581,6 @@ accounting_set_wakeup_time(void)
* to be chosen than the last half. */ * to be chosen than the last half. */
interval_wakeup_time = interval_start_time + interval_wakeup_time = interval_start_time +
(get_uint32(digest) % time_to_consider); (get_uint32(digest) % time_to_consider);
format_iso_time(buf, interval_wakeup_time);
} }
{ {