diff src/os/unix/ngx_posix_init.c @ 4506:14f8e8a0cc77 stable-1.0

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 05 Mar 2012 12:10:09 +0000
parents 4919fb357a5d
children 4c36e15651f7
line wrap: on
line diff
--- 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;
     }