n_seconds_active_in_interval = 0;
}
-
static INLINE int time_to_record_bandwidth_usage(time_t now)
{
/* Note every 5 minutes */
static uint64_t last_written_bytes_noted = 0;
static time_t last_time_noted = 0;
- /* ???? Maybe only do this if accountingmaxkb is set ?
- if (!get_options()->AccountingMaxKB)
- return 0;
- */
-
if (last_time_noted + NOTE_INTERVAL <= now ||
last_read_bytes_noted + NOTE_BYTES <= n_bytes_read_in_interval ||
last_written_bytes_noted + NOTE_BYTES <= n_bytes_written_in_interval ||
n_days_to_consider = n_days_in_interval - n_days_to_exhaust_bw;
+ /* XXX can we simplify this just by picking a random (non-deterministic)
+ * time to be up? If we go down and come up, then we pick a new one. Is
+ * that good enough? -RD */
while (((unsigned char)digest[0]) > n_days_to_consider)
crypto_digest(digest, digest, DIGEST_LEN);
last_rotated_certificate = now;
if (last_rotated_certificate+MAX_SSL_KEY_LIFETIME < now) {
log_fn(LOG_INFO,"Rotating tls context.");
- if (tor_tls_context_new(get_identity_key(), 1, get_options()->Nickname,
+ if (tor_tls_context_new(get_identity_key(), 1, options->Nickname,
MAX_SSL_KEY_LIFETIME) < 0) {
log_fn(LOG_WARN, "Error reinitializing TLS context");
}
/** 1c. If we have to change the accounting interval or record
* bandwidth used in this accounting interval, do so. */
- accounting_run_housekeeping(now);
+ if (options->AccountingMaxKB)
+ accounting_run_housekeeping(now);
/** 2. Every DirFetchPostPeriod seconds, we get a new directory and upload
* our descriptor (if we've passed our internal checks). */
}
rend_cache_clean(); /* should this go elsewhere? */
- time_to_fetch_directory = now + get_options()->DirFetchPostPeriod;
+ time_to_fetch_directory = now + options->DirFetchPostPeriod;
}
/** 3a. Every second, we examine pending circuits and prune the
seconds_elapsed = current_second ? (now.tv_sec - current_second) : 0;
stats_n_bytes_read += bytes_read;
stats_n_bytes_written += bytes_written;
- accounting_add_bytes(bytes_read, bytes_written, seconds_elapsed);
+ if (get_options()->AccountingMaxKB)
+ accounting_add_bytes(bytes_read, bytes_written, seconds_elapsed);
control_event_bandwidth_used((uint32_t)bytes_read,(uint32_t)bytes_written);
connection_bucket_refill(&now);
}
/* Set up accounting */
- configure_accounting(time(NULL));
+ if (get_options()->AccountingMaxKB)
+ configure_accounting(time(NULL));
/* load the routers file, or assign the defaults. */
if(router_reload_router_list()) {