Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-11-15 16:30:52 +0300
committerIgor Sysoev <igor@sysoev.ru>2005-11-15 16:30:52 +0300
commit0e5dc5cff692f532f0ccb2655ab196995f4233e0 (patch)
treef56f40e788077b9820ebb45f3e0739fabb7be421 /src/os/unix/ngx_process_cycle.c
parent2a7f83eceda87e520f36bbfb16b82b8c2d6606d7 (diff)
nginx-0.3.10-RELEASE importrelease-0.3.10
*) Change: the "valid_referers" directive and the "$invalid_referer" variable were moved to the new ngx_http_referer_module from the ngx_http_rewrite_module. *) Change: the "$apache_bytes_sent" variable name was changed to "$body_bytes_sent". *) Feature: the "$sent_http_..." variables. *) Feature: the "if" directive supports the "=" and "!=" operations. *) Feature: the "proxy_pass" directive supports the HTTPS protocol. *) Feature: the "proxy_set_body" directive. *) Feature: the "post_action" directive. *) Feature: the ngx_http_empty_gif_module. *) Feature: the "worker_cpu_affinity" directive for Linux. *) Bugfix: the "rewrite" directive did not unescape URI part in redirect, now it is unescaped except the %00-%25 and %7F-%FF characters. *) Bugfix: nginx could not be built by the icc 9.0 compiler. *) Bugfix: if the SSI was enabled for zero size static file, then the chunked response was encoded incorrectly.
Diffstat (limited to 'src/os/unix/ngx_process_cycle.c')
-rw-r--r--src/os/unix/ngx_process_cycle.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index ddc10c8a5..7adcc6ef7 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -58,7 +58,8 @@ ngx_int_t ngx_threads_n;
#endif
-u_char master_process[] = "master process";
+u_long cpu_affinity;
+static u_char master_process[] = "master process";
void
@@ -312,14 +313,17 @@ ngx_single_process_cycle(ngx_cycle_t *cycle)
static void
ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
{
- ngx_int_t i;
+ ngx_int_t i, s;
ngx_channel_t ch;
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start worker processes");
ch.command = NGX_CMD_OPEN_CHANNEL;
- while (n--) {
+ 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);
@@ -327,11 +331,11 @@ ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
ch.slot = ngx_process_slot;
ch.fd = ngx_processes[ngx_process_slot].channel[0];
- for (i = 0; i < ngx_last_process; i++) {
+ for (s = 0; s < ngx_last_process; s++) {
- if (i == ngx_process_slot
- || ngx_processes[i].pid == -1
- || ngx_processes[i].channel[0] == -1)
+ if (s == ngx_process_slot
+ || ngx_processes[s].pid == -1
+ || ngx_processes[s].channel[0] == -1)
{
continue;
}
@@ -339,12 +343,12 @@ ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0,
"pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d",
ch.slot, ch.pid, ch.fd,
- i, ngx_processes[i].pid,
- ngx_processes[i].channel[0]);
+ s, ngx_processes[s].pid,
+ ngx_processes[s].channel[0]);
/* TODO: NGX_AGAIN */
- ngx_write_channel(ngx_processes[i].channel[0],
+ ngx_write_channel(ngx_processes[s].channel[0],
&ch, sizeof(ngx_channel_t), cycle->log);
}
}
@@ -817,6 +821,20 @@ ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
}
}
+#if (NGX_HAVE_SCHED_SETAFFINITY)
+
+ if (cpu_affinity) {
+ ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
+ "sched_setaffinity(0x%08Xl)", cpu_affinity);
+
+ if (sched_setaffinity(0, 32, (cpu_set_t *) &cpu_affinity) == -1) {
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
+ "sched_setaffinity(0x%08Xl) failed", cpu_affinity);
+ }
+ }
+
+#endif
+
#if (NGX_HAVE_PR_SET_DUMPABLE)
/* allow coredump after setuid() in Linux 2.4.x */
@@ -849,7 +867,7 @@ ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
/*
* disable deleting previous events for the listening sockets because
* in the worker processes there are no events at all at this point
- */
+ */
ls = cycle->listening.elts;
for (i = 0; i < cycle->listening.nelts; i++) {
ls[i].previous = NULL;