mirror of https://github.com/nginx/nginx
Merge 1c59ff16d3 into 7c2524a692
This commit is contained in:
commit
4079213c5f
11
auto/unix
11
auto/unix
|
|
@ -292,6 +292,17 @@ ngx_feature_test="cpu_set_t mask;
|
|||
. auto/feature
|
||||
|
||||
|
||||
ngx_feature="sched_getaffinity()"
|
||||
ngx_feature_name="NGX_HAVE_SCHED_GETAFFINITY"
|
||||
ngx_feature_run=no
|
||||
ngx_feature_incs="#include <sched.h>"
|
||||
ngx_feature_path=
|
||||
ngx_feature_libs=
|
||||
ngx_feature_test="cpu_set_t set;
|
||||
sched_getaffinity(0, sizeof(set), &set);"
|
||||
. auto/feature
|
||||
|
||||
|
||||
ngx_feature="SO_SETFIB"
|
||||
ngx_feature_name="NGX_HAVE_SETFIB"
|
||||
ngx_feature_run=no
|
||||
|
|
|
|||
|
|
@ -64,6 +64,28 @@ ngx_os_init(ngx_log_t *log)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if (NGX_HAVE_SCHED_GETAFFINITY)
|
||||
if (ngx_ncpu > 0) {
|
||||
int err;
|
||||
size_t sz;
|
||||
cpu_set_t *mask;
|
||||
|
||||
mask = CPU_ALLOC(ngx_ncpu);
|
||||
if (mask == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
sz = CPU_ALLOC_SIZE(ngx_ncpu);
|
||||
|
||||
err = sched_getaffinity(0, sz, mask);
|
||||
if (err == 0) {
|
||||
ngx_ncpu = CPU_COUNT_S(sz, mask);
|
||||
}
|
||||
|
||||
CPU_FREE(mask);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ngx_ncpu < 1) {
|
||||
ngx_ncpu = 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue