fix a bug in configuring accounting in options_act()

svn:r2881
This commit is contained in:
Roger Dingledine 2004-11-15 04:01:31 +00:00
parent 47993ae6fb
commit ee591be3f2
4 changed files with 13 additions and 3 deletions

View File

@ -311,7 +311,7 @@ options_act(void) {
}
/* Set up accounting */
if (get_options()->AccountingMaxKB)
if (accounting_is_enabled(options))
configure_accounting(time(NULL));
if(retry_all_listeners(1) < 0) {

View File

@ -91,6 +91,15 @@ static void accounting_set_wakeup_time(void);
* Functions for bandwidth accounting.
* ************/
/** If we want to manage the accounting system and potentially
* hibernate, return 1, else return 0.
*/
int accounting_is_enabled(or_options_t *options) {
if (options->AccountingMaxKB)
return 1;
return 0;
}
/** Called from main.c to tell us that <b>seconds</b> seconds have
* passed, <b>n_read</b> bytes have been read, and <b>n_written</b>
* bytes have been written. */

View File

@ -556,7 +556,7 @@ static void run_scheduled_events(time_t now) {
/** 1c. If we have to change the accounting interval or record
* bandwidth used in this accounting interval, do so. */
if (options->AccountingMaxKB)
if (accounting_is_enabled(options))
accounting_run_housekeeping(now);
/** 2. Every DirFetchPostPeriod seconds, we get a new directory and
@ -700,7 +700,7 @@ static int prepare_for_poll(void) {
seconds_elapsed = current_second ? (now.tv_sec - current_second) : 0;
stats_n_bytes_read += bytes_read;
stats_n_bytes_written += bytes_written;
if (get_options()->AccountingMaxKB)
if (accounting_is_enabled(get_options()))
accounting_add_bytes(bytes_read, bytes_written, seconds_elapsed);
control_event_bandwidth_used((uint32_t)bytes_read,(uint32_t)bytes_written);

View File

@ -1324,6 +1324,7 @@ int dns_resolve(connection_t *exitconn);
/********************************* hibernate.c **********************/
int accounting_is_enabled(or_options_t *options);
void configure_accounting(time_t now);
void accounting_run_housekeeping(time_t now);
void accounting_add_bytes(size_t n_read, size_t n_written, int seconds);