summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2012-03-05 12:10:09 +0000
committerMaxim Dounin <mdounin@mdounin.ru>2012-03-05 12:10:09 +0000
commit9ec45d5f6fde95be4a19669d631044cfe7b52cb6 (patch)
tree20ea7e72b5192fce5e1544f8fe9ab55cdc6cf832 /src
parent658587e7d250381a95f32f45390fa880b00a4f5e (diff)
downloadnginx-9ec45d5f6fde95be4a19669d631044cfe7b52cb6.tar.gz
nginx-9ec45d5f6fde95be4a19669d631044cfe7b52cb6.tar.bz2
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.
Diffstat (limited to 'src')
-rw-r--r--src/os/unix/ngx_posix_init.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
index 02642bd7c..eea65a903 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -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;
}