}
/* Set up accounting */
- if (get_options()->AccountingMaxKB)
+ if (accounting_is_enabled(options))
configure_accounting(time(NULL));
if(retry_all_listeners(1) < 0) {
* 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. */
/** 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
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);
/********************************* 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);