diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-09-28 14:42:52 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-09-28 14:42:52 -0400 |
commit | 3efaa30727f23f316941b6ac861a7027f8204769 (patch) | |
tree | d671760bb22f7010a2c2695f0a2891fc7393a9c2 /src/or/config.c | |
parent | c58b7a109559a609f642d1fb7eb2e55b0d566ba5 (diff) | |
parent | 73d93c033d3f4b9c95e8f3a5cc7e4a255d523b84 (diff) | |
download | tor-3efaa30727f23f316941b6ac861a7027f8204769.tar tor-3efaa30727f23f316941b6ac861a7027f8204769.tar.gz |
Merge branch 'iocp_option'
Diffstat (limited to 'src/or/config.c')
-rw-r--r-- | src/or/config.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/or/config.c b/src/or/config.c index 6d8addeb2..23cad9268 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -224,6 +224,7 @@ static config_var_t _option_vars[] = { V(DirReqStatistics, BOOL, "0"), VAR("DirServer", LINELIST, DirServers, NULL), V(DisableAllSwap, BOOL, "0"), + V(DisableIOCP, BOOL, "1"), V(DNSPort, UINT, "0"), V(DNSListenAddress, LINELIST, NULL), V(DownloadExtraInfo, BOOL, "0"), @@ -306,7 +307,7 @@ static config_var_t _option_vars[] = { V(WarnUnsafeSocks, BOOL, "1"), V(NoPublish, BOOL, "0"), VAR("NodeFamily", LINELIST, NodeFamilies, NULL), - V(NumCpus, UINT, "1"), + V(NumCpus, UINT, "0"), V(NumEntryGuards, UINT, "3"), V(ORListenAddress, LINELIST, NULL), V(ORPort, UINT, "0"), @@ -554,7 +555,7 @@ static int is_listening_on_low_port(uint16_t port_option, static uint64_t config_parse_memunit(const char *s, int *ok); static int config_parse_interval(const char *s, int *ok); -static void init_libevent(void); +static void init_libevent(const or_options_t *options); static int opt_streq(const char *s1, const char *s2); /** Magic value for or_options_t. */ @@ -955,7 +956,7 @@ options_act_reversible(or_options_t *old_options, char **msg) /* Set up libevent. (We need to do this before we can register the * listeners as listeners.) */ if (running_tor && !libevent_initialized) { - init_libevent(); + init_libevent(options); libevent_initialized = 1; } @@ -4891,13 +4892,29 @@ config_parse_interval(const char *s, int *ok) return (int)r; } +/** Return the number of cpus configured in <b>options</b>. If we are + * told to auto-detect the number of cpus, return the auto-detected number. */ +int +get_num_cpus(const or_options_t *options) +{ + if (options->NumCpus == 0) { + int n = compute_num_cpus(); + return (n >= 1) ? n : 1; + } else { + return options->NumCpus; + } +} + /** * Initialize the libevent library. */ static void -init_libevent(void) +init_libevent(const or_options_t *options) { const char *badness=NULL; + tor_libevent_cfg cfg; + + tor_assert(options); configure_libevent_logging(); /* If the kernel complains that some method (say, epoll) doesn't @@ -4907,7 +4924,11 @@ init_libevent(void) tor_check_libevent_header_compatibility(); - tor_libevent_initialize(); + memset(&cfg, 0, sizeof(cfg)); + cfg.disable_iocp = options->DisableIOCP; + cfg.num_cpus = get_num_cpus(options); + + tor_libevent_initialize(&cfg); suppress_libevent_log_msg(NULL); |