Skip to content
Snippets Groups Projects
Commit 8d29866b authored by Nick Mathewson's avatar Nick Mathewson :game_die:
Browse files

Merge remote-tracking branch 'public/bug8002' into maint-0.2.4

parents de7e99f8 22804c03
No related branches found
No related tags found
No related merge requests found
o Minor bugfixes:
- When autodetecting the number of CPUs, use the number of available
CPUs in preferernce to the number of configured CPUs. Inform the
user if this reduces the number of avialable CPUs. Fix for bug 8002.
Bugfix on 0.2.3.1-alpha.
......@@ -2313,8 +2313,33 @@ compute_num_cpus_impl(void)
return (int)info.dwNumberOfProcessors;
else
return -1;
#elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_CONF)
long cpus = sysconf(_SC_NPROCESSORS_CONF);
#elif defined(HAVE_SYSCONF)
#ifdef _SC_NPROCESSORS_CONF
long cpus_conf = sysconf(_SC_NPROCESSORS_CONF);
#else
long cpus_conf = -1;
#endif
#ifdef _SC_NPROCESSORS_ONLN
long cpus_onln = sysconf(_SC_NPROCESSORS_ONLN);
#else
long cpus_onln = -1;
#endif
long cpus = -1;
if (cpus_conf > 0 && cpus_onln < 0) {
cpus = cpus_conf;
} else if (cpus_onln > 0 && cpus_conf < 0) {
cpus = cpus_onln;
} else if (cpus_onln > 0 && cpus_conf > 0) {
if (cpus_onln < cpus_conf) {
log_notice(LD_GENERAL, "I think we have %ld CPUS, but only %ld of them "
"are available. Telling Tor to only use %ld. You can over"
"ride this with the NumCPUs option",
cpus_conf, cpus_onln, cpus_onln);
}
cpus = cpus_onln;
}
if (cpus >= 1 && cpus < INT_MAX)
return (int)cpus;
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment