static ngx_uint_t ngx_reap_children(ngx_cycle_t *cycle);
static void ngx_master_process_exit(ngx_cycle_t *cycle);
static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
-static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority);
+static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker);
static void ngx_worker_process_exit(ngx_cycle_t *cycle);
static void ngx_channel_handler(ngx_event_t *ev);
#if (NGX_THREADS)
#endif
-uint64_t cpu_affinity;
static u_char master_process[] = "master process";
for (i = 0; i < n; i++) {
- cpu_affinity = ngx_get_cpu_affinity(i);
-
- ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL,
- "worker process", type);
+ ngx_spawn_process(cycle, ngx_worker_process_cycle,
+ (void *) (intptr_t) i, "worker process", type);
ch.pid = ngx_processes[ngx_process_slot].pid;
ch.slot = ngx_process_slot;
ngx_pass_open_channel(cycle, &ch);
}
-
- cpu_affinity = 0;
}
static void
ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
{
+ ngx_int_t worker = (intptr_t) data;
+
ngx_uint_t i;
ngx_connection_t *c;
ngx_process = NGX_PROCESS_WORKER;
- ngx_worker_process_init(cycle, 1);
+ ngx_worker_process_init(cycle, worker);
ngx_setproctitle("worker process");
static void
-ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
+ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker)
{
sigset_t set;
+ uint64_t cpu_affinity;
ngx_int_t n;
ngx_uint_t i;
struct rlimit rlmt;
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
- if (priority && ccf->priority != 0) {
+ if (worker >= 0 && ccf->priority != 0) {
if (setpriority(PRIO_PROCESS, 0, ccf->priority) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"setpriority(%d) failed", ccf->priority);
}
}
- if (cpu_affinity) {
- ngx_setaffinity(cpu_affinity, cycle->log);
+ if (worker >= 0) {
+ cpu_affinity = ngx_get_cpu_affinity(worker);
+
+ if (cpu_affinity) {
+ ngx_setaffinity(cpu_affinity, cycle->log);
+ }
}
#if (NGX_HAVE_PR_SET_DUMPABLE)
ngx_process = NGX_PROCESS_HELPER;
- ngx_worker_process_init(cycle, 0);
+ ngx_worker_process_init(cycle, -1);
ngx_close_listening_sockets(cycle);