Merge of r4460: ngx_ncpu detection for most *nix platforms.

This inaccurate detection by using sysconf(_SC_NPROCESSORS_ONLN) can improve
usage of the mutex lock optimization on multicore systems.
This commit is contained in:
Maxim Dounin 2012-03-05 12:10:09 +00:00
parent 658587e7d2
commit 9ec45d5f6f
2 changed files with 16 additions and 0 deletions

View File

@ -707,3 +707,13 @@ ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="struct dirent dir; dir.d_type = DT_REG"
. auto/feature
ngx_feature="sysconf(_SC_NPROCESSORS_ONLN)"
ngx_feature_name="NGX_HAVE_SC_NPROCESSORS_ONLN"
ngx_feature_run=no
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="sysconf(_SC_NPROCESSORS_ONLN)"
. auto/feature

View File

@ -47,7 +47,13 @@ ngx_os_init(ngx_log_t *log)
for (n = ngx_pagesize; n >>= 1; ngx_pagesize_shift++) { /* void */ }
#if (NGX_HAVE_SC_NPROCESSORS_ONLN)
if (ngx_ncpu == 0) {
ngx_ncpu = sysconf(_SC_NPROCESSORS_ONLN);
}
#endif
if (ngx_ncpu < 1) {
ngx_ncpu = 1;
}