diff options
author | Roger Dingledine <arma@torproject.org> | 2004-11-15 04:01:31 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2004-11-15 04:01:31 +0000 |
commit | ee591be3f2743d31f1ac5c7d2de74adb773fbec9 (patch) | |
tree | 0daff29156c24e4f330d07fe9756b5e8f3c56c2a /src/or | |
parent | 47993ae6fbb84c22a5811e00390c20e03bae790b (diff) | |
download | tor-ee591be3f2743d31f1ac5c7d2de74adb773fbec9.tar.gz tor-ee591be3f2743d31f1ac5c7d2de74adb773fbec9.zip |
fix a bug in configuring accounting in options_act()
svn:r2881
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/config.c | 2 | ||||
-rw-r--r-- | src/or/hibernate.c | 9 | ||||
-rw-r--r-- | src/or/main.c | 4 | ||||
-rw-r--r-- | src/or/or.h | 1 |
4 files changed, 13 insertions, 3 deletions
diff --git a/src/or/config.c b/src/or/config.c index 95e0308fdc..22dc29ed76 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -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) { diff --git a/src/or/hibernate.c b/src/or/hibernate.c index 7667a8a230..f972479246 100644 --- a/src/or/hibernate.c +++ b/src/or/hibernate.c @@ -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. */ diff --git a/src/or/main.c b/src/or/main.c index f07641385e..81e32fe700 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -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); diff --git a/src/or/or.h b/src/or/or.h index 35cc304a17..72fa6f80aa 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -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); |