diff options
author | Valentin Bartenev <vbart@nginx.com> | 2012-02-10 11:24:19 +0000 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2012-02-10 11:24:19 +0000 |
commit | 891b43db32ad7b21bc9e37f42751cb6fc85a3a73 (patch) | |
tree | b4b0c8a7353d8b727a7e50820b320432b6a26aca /src/os/unix/ngx_posix_init.c | |
parent | 9e8708cbd6da2ba2a2bdbc93c666aeee2dfefddc (diff) | |
download | nginx-891b43db32ad7b21bc9e37f42751cb6fc85a3a73.tar.gz nginx-891b43db32ad7b21bc9e37f42751cb6fc85a3a73.zip |
Added 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/os/unix/ngx_posix_init.c')
-rw-r--r-- | src/os/unix/ngx_posix_init.c | 6 |
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; } |