Skip to content

Commit dec92bf

Browse files
committed
set affinity earlier for children
1 parent 3ca57f6 commit dec92bf

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

sapi/fpm/fpm/fpm_unix.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,20 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
433433
zlog(ZLOG_SYSERROR, "[pool %s] failed to set rlimit_core for this pool. Please check your system limits or decrease rlimit_core. setrlimit(RLIMIT_CORE, %d)", wp->config->name, wp->config->rlimit_core);
434434
}
435435
}
436+
#if HAVE_FPM_CPUAFFINITY
437+
if (is_root && wp->config->process_cpumask) {
438+
int fcpu, lcpu;
439+
440+
if (0 > fpm_cpusrange(wp->config->process_cpumask, &fcpu, &lcpu)) {
441+
zlog(ZLOG_SYSERROR, "[pool %s] failed to fpm_cpusrange(%s)", wp->config->name, wp->config->process_cpumask);
442+
return -1;
443+
}
444+
if (0 > fpm_setcpuaffinity(fcpu, lcpu)) {
445+
zlog(ZLOG_SYSERROR, "[pool %s] failed to fpm_setcpuaffinity(%s)", wp->config->name, wp->config->process_cpumask);
446+
return -1;
447+
}
448+
}
449+
#endif
436450

437451
if (is_root && wp->config->chroot && *wp->config->chroot) {
438452
if (0 > chroot(wp->config->chroot)) {
@@ -462,20 +476,6 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
462476
}
463477
}
464478

465-
#if HAVE_FPM_CPUAFFINITY
466-
if (wp->config->process_cpumask) {
467-
int fcpu, lcpu;
468-
469-
if (0 > fpm_cpusrange(wp->config->process_cpumask, &fcpu, &lcpu)) {
470-
zlog(ZLOG_SYSERROR, "[pool %s] failed to fpm_cpusrange(%s)", wp->config->name, wp->config->process_cpumask);
471-
return -1;
472-
}
473-
if (0 > fpm_setcpuaffinity(fcpu, lcpu)) {
474-
zlog(ZLOG_SYSERROR, "[pool %s] failed to fpm_setcpuaffinity(%s)", wp->config->name, wp->config->process_cpumask);
475-
return -1;
476-
}
477-
}
478-
#endif
479479
if (wp->set_gid) {
480480
if (0 > setgid(wp->set_gid)) {
481481
zlog(ZLOG_SYSERROR, "[pool %s] failed to setgid(%d)", wp->config->name, wp->set_gid);
@@ -699,7 +699,7 @@ int fpm_unix_init_main(void)
699699
int fcpu, lcpu;
700700

701701
if (0 > fpm_cpusrange(fpm_global_config.process_cpumask, &fcpu, &lcpu)) {
702-
zlog(ZLOG_SYSERROR, "failed to fpm_cpurange(%s)", fpm_global_config.process_cpumask);
702+
zlog(ZLOG_SYSERROR, "failed to fpm_cpusrange(%s)", fpm_global_config.process_cpumask);
703703
return -1;
704704
}
705705
if (0 > fpm_setcpuaffinity(fcpu, lcpu)) {

0 commit comments

Comments
 (0)