Mercurial > hg > nginx
comparison src/os/unix/ngx_process_cycle.c @ 577:4d9ea73a627a release-0.3.10
nginx-0.3.10-RELEASE import
*) 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.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 15 Nov 2005 13:30:52 +0000 |
parents | 58475592100c |
children | 284cc140593b |
comparison
equal
deleted
inserted
replaced
576:3e0b61c26426 | 577:4d9ea73a627a |
---|---|
56 volatile ngx_thread_t ngx_threads[NGX_MAX_THREADS]; | 56 volatile ngx_thread_t ngx_threads[NGX_MAX_THREADS]; |
57 ngx_int_t ngx_threads_n; | 57 ngx_int_t ngx_threads_n; |
58 #endif | 58 #endif |
59 | 59 |
60 | 60 |
61 u_char master_process[] = "master process"; | 61 u_long cpu_affinity; |
62 static u_char master_process[] = "master process"; | |
62 | 63 |
63 | 64 |
64 void | 65 void |
65 ngx_master_process_cycle(ngx_cycle_t *cycle) | 66 ngx_master_process_cycle(ngx_cycle_t *cycle) |
66 { | 67 { |
310 | 311 |
311 | 312 |
312 static void | 313 static void |
313 ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type) | 314 ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type) |
314 { | 315 { |
315 ngx_int_t i; | 316 ngx_int_t i, s; |
316 ngx_channel_t ch; | 317 ngx_channel_t ch; |
317 | 318 |
318 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start worker processes"); | 319 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start worker processes"); |
319 | 320 |
320 ch.command = NGX_CMD_OPEN_CHANNEL; | 321 ch.command = NGX_CMD_OPEN_CHANNEL; |
321 | 322 |
322 while (n--) { | 323 for (i = 0; i < n; i++) { |
324 | |
325 cpu_affinity = ngx_get_cpu_affinity(i); | |
326 | |
323 ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL, | 327 ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL, |
324 "worker process", type); | 328 "worker process", type); |
325 | 329 |
326 ch.pid = ngx_processes[ngx_process_slot].pid; | 330 ch.pid = ngx_processes[ngx_process_slot].pid; |
327 ch.slot = ngx_process_slot; | 331 ch.slot = ngx_process_slot; |
328 ch.fd = ngx_processes[ngx_process_slot].channel[0]; | 332 ch.fd = ngx_processes[ngx_process_slot].channel[0]; |
329 | 333 |
330 for (i = 0; i < ngx_last_process; i++) { | 334 for (s = 0; s < ngx_last_process; s++) { |
331 | 335 |
332 if (i == ngx_process_slot | 336 if (s == ngx_process_slot |
333 || ngx_processes[i].pid == -1 | 337 || ngx_processes[s].pid == -1 |
334 || ngx_processes[i].channel[0] == -1) | 338 || ngx_processes[s].channel[0] == -1) |
335 { | 339 { |
336 continue; | 340 continue; |
337 } | 341 } |
338 | 342 |
339 ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0, | 343 ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0, |
340 "pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d", | 344 "pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d", |
341 ch.slot, ch.pid, ch.fd, | 345 ch.slot, ch.pid, ch.fd, |
342 i, ngx_processes[i].pid, | 346 s, ngx_processes[s].pid, |
343 ngx_processes[i].channel[0]); | 347 ngx_processes[s].channel[0]); |
344 | 348 |
345 /* TODO: NGX_AGAIN */ | 349 /* TODO: NGX_AGAIN */ |
346 | 350 |
347 ngx_write_channel(ngx_processes[i].channel[0], | 351 ngx_write_channel(ngx_processes[s].channel[0], |
348 &ch, sizeof(ngx_channel_t), cycle->log); | 352 &ch, sizeof(ngx_channel_t), cycle->log); |
349 } | 353 } |
350 } | 354 } |
351 } | 355 } |
352 | 356 |
815 /* fatal */ | 819 /* fatal */ |
816 exit(2); | 820 exit(2); |
817 } | 821 } |
818 } | 822 } |
819 | 823 |
824 #if (NGX_HAVE_SCHED_SETAFFINITY) | |
825 | |
826 if (cpu_affinity) { | |
827 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, | |
828 "sched_setaffinity(0x%08Xl)", cpu_affinity); | |
829 | |
830 if (sched_setaffinity(0, 32, (cpu_set_t *) &cpu_affinity) == -1) { | |
831 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
832 "sched_setaffinity(0x%08Xl) failed", cpu_affinity); | |
833 } | |
834 } | |
835 | |
836 #endif | |
837 | |
820 #if (NGX_HAVE_PR_SET_DUMPABLE) | 838 #if (NGX_HAVE_PR_SET_DUMPABLE) |
821 | 839 |
822 /* allow coredump after setuid() in Linux 2.4.x */ | 840 /* allow coredump after setuid() in Linux 2.4.x */ |
823 | 841 |
824 if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) { | 842 if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) { |
847 ngx_init_temp_number(); | 865 ngx_init_temp_number(); |
848 | 866 |
849 /* | 867 /* |
850 * disable deleting previous events for the listening sockets because | 868 * disable deleting previous events for the listening sockets because |
851 * in the worker processes there are no events at all at this point | 869 * in the worker processes there are no events at all at this point |
852 */ | 870 */ |
853 ls = cycle->listening.elts; | 871 ls = cycle->listening.elts; |
854 for (i = 0; i < cycle->listening.nelts; i++) { | 872 for (i = 0; i < cycle->listening.nelts; i++) { |
855 ls[i].previous = NULL; | 873 ls[i].previous = NULL; |
856 } | 874 } |
857 | 875 |