diff options
Diffstat (limited to 'src/or/config.c')
-rw-r--r-- | src/or/config.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/or/config.c b/src/or/config.c index 46c090e65e..ced4288f00 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -43,6 +43,7 @@ #include "util.h" #include "routerlist.h" #include "routerset.h" +#include "scheduler.h" #include "statefile.h" #include "transports.h" #include "ext_orport.h" @@ -368,6 +369,9 @@ static config_var_t option_vars_[] = { V(ServerDNSSearchDomains, BOOL, "0"), V(ServerDNSTestAddresses, CSV, "www.google.com,www.mit.edu,www.yahoo.com,www.slashdot.org"), + V(SchedulerLowWaterMark, MEMUNIT, "16 kB"), + V(SchedulerHighWaterMark, MEMUNIT, "32 kB"), + V(SchedulerMaxFlushCells, UINT, "16"), V(ShutdownWaitLength, INTERVAL, "30 seconds"), V(SocksListenAddress, LINELIST, NULL), V(SocksPolicy, LINELIST, NULL), @@ -1045,6 +1049,14 @@ options_act_reversible(const or_options_t *old_options, char **msg) if (running_tor && !libevent_initialized) { init_libevent(options); libevent_initialized = 1; + + /* + * Initialize the scheduler - this has to come after + * options_init_from_torrc() sets up libevent - why yes, that seems + * completely sensible to hide the libevent setup in the option parsing + * code! It also needs to happen before init_keys(), so it needs to + * happen here too. How yucky. */ + scheduler_init(); } /* Adjust the port configuration so we can launch listeners. */ @@ -1526,6 +1538,25 @@ options_act(const or_options_t *old_options) return -1; } + /* Set up scheduler thresholds */ + if (options->SchedulerLowWaterMark > 0 && + options->SchedulerHighWaterMark > options->SchedulerLowWaterMark) { + scheduler_set_watermarks(options->SchedulerLowWaterMark, + options->SchedulerHighWaterMark, + (options->SchedulerMaxFlushCells > 0) ? + options->SchedulerMaxFlushCells : 16); + } else { + if (options->SchedulerLowWaterMark == 0) { + log_warn(LD_GENERAL, "Bad SchedulerLowWaterMark option"); + } + + if (options->SchedulerHighWaterMark <= options->SchedulerLowWaterMark) { + log_warn(LD_GENERAL, "Bad SchedulerHighWaterMark option"); + } + + return -1; + } + /* Set up accounting */ if (accounting_parse_options(options, 0)<0) { log_warn(LD_CONFIG,"Error in accounting options"); @@ -2269,8 +2300,8 @@ resolve_my_address(int warn_severity, const or_options_t *options, /** Return true iff <b>addr</b> is judged to be on the same network as us, or * on a private network. */ -int -is_local_addr(const tor_addr_t *addr) +MOCK_IMPL(int, +is_local_addr, (const tor_addr_t *addr)) { if (tor_addr_is_internal(addr, 0)) return 1; |