Mercurial > hg > nginx-vendor-0-6
comparison src/core/nginx.c @ 126:df17fbafec8f NGINX_0_3_10
nginx 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.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 15 Nov 2005 00:00:00 +0300 |
parents | 408f195b3482 |
children | 8e6d4d96ec4c |
comparison
equal
deleted
inserted
replaced
125:97504de1f89e | 126:df17fbafec8f |
---|---|
15 static ngx_int_t ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv); | 15 static ngx_int_t ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv); |
16 static void *ngx_core_module_create_conf(ngx_cycle_t *cycle); | 16 static void *ngx_core_module_create_conf(ngx_cycle_t *cycle); |
17 static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf); | 17 static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf); |
18 static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | 18 static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
19 static char *ngx_set_priority(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | 19 static char *ngx_set_priority(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
20 static char *ngx_set_cpu_affinity(ngx_conf_t *cf, ngx_command_t *cmd, | |
21 void *conf); | |
20 | 22 |
21 | 23 |
22 static ngx_conf_enum_t ngx_debug_points[] = { | 24 static ngx_conf_enum_t ngx_debug_points[] = { |
23 { ngx_string("stop"), NGX_DEBUG_POINTS_STOP }, | 25 { ngx_string("stop"), NGX_DEBUG_POINTS_STOP }, |
24 { ngx_string("abort"), NGX_DEBUG_POINTS_ABORT }, | 26 { ngx_string("abort"), NGX_DEBUG_POINTS_ABORT }, |
25 { ngx_null_string, 0 } | 27 { ngx_null_string, 0 } |
26 }; | 28 }; |
27 | 29 |
28 | 30 |
29 static ngx_command_t ngx_core_commands[] = { | 31 static ngx_command_t ngx_core_commands[] = { |
30 | 32 |
31 { ngx_string("daemon"), | 33 { ngx_string("daemon"), |
78 NULL }, | 80 NULL }, |
79 | 81 |
80 { ngx_string("worker_priority"), | 82 { ngx_string("worker_priority"), |
81 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | 83 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, |
82 ngx_set_priority, | 84 ngx_set_priority, |
85 0, | |
86 0, | |
87 NULL }, | |
88 | |
89 { ngx_string("worker_cpu_affinity"), | |
90 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_1MORE, | |
91 ngx_set_cpu_affinity, | |
83 0, | 92 0, |
84 0, | 93 0, |
85 NULL }, | 94 NULL }, |
86 | 95 |
87 { ngx_string("worker_rlimit_nofile"), | 96 { ngx_string("worker_rlimit_nofile"), |
535 * set by pcalloc() | 544 * set by pcalloc() |
536 * | 545 * |
537 * ccf->pid = NULL; | 546 * ccf->pid = NULL; |
538 * ccf->oldpid = NULL; | 547 * ccf->oldpid = NULL; |
539 * ccf->priority = 0; | 548 * ccf->priority = 0; |
549 * ccf->cpu_affinity_n = 0; | |
550 * ccf->cpu_affinity = NULL; | |
540 */ | 551 */ |
541 | 552 |
542 ccf->daemon = NGX_CONF_UNSET; | 553 ccf->daemon = NGX_CONF_UNSET; |
543 ccf->master = NGX_CONF_UNSET; | 554 ccf->master = NGX_CONF_UNSET; |
544 ccf->timer_resolution = NGX_CONF_UNSET_MSEC; | 555 ccf->timer_resolution = NGX_CONF_UNSET_MSEC; |
576 ngx_conf_init_msec_value(ccf->timer_resolution, 0); | 587 ngx_conf_init_msec_value(ccf->timer_resolution, 0); |
577 | 588 |
578 ngx_conf_init_value(ccf->worker_processes, 1); | 589 ngx_conf_init_value(ccf->worker_processes, 1); |
579 ngx_conf_init_value(ccf->debug_points, 0); | 590 ngx_conf_init_value(ccf->debug_points, 0); |
580 | 591 |
592 #if (NGX_HAVE_SCHED_SETAFFINITY) | |
593 | |
594 if (ccf->cpu_affinity_n | |
595 && ccf->cpu_affinity_n != 1 | |
596 && ccf->cpu_affinity_n != (ngx_uint_t) ccf->worker_processes) | |
597 { | |
598 ngx_log_error(NGX_LOG_WARN, cycle->log, 0, | |
599 "number of the \"worker_processes\" is not equal to " | |
600 "the number of the \"worker_cpu_affinity\" mask, " | |
601 "using last mask for remaining worker processes"); | |
602 } | |
603 | |
604 #endif | |
605 | |
581 #if (NGX_THREADS) | 606 #if (NGX_THREADS) |
607 | |
582 ngx_conf_init_value(ccf->worker_threads, 0); | 608 ngx_conf_init_value(ccf->worker_threads, 0); |
583 ngx_threads_n = ccf->worker_threads; | 609 ngx_threads_n = ccf->worker_threads; |
584 ngx_conf_init_size_value(ccf->thread_stack_size, 2 * 1024 * 1024); | 610 ngx_conf_init_size_value(ccf->thread_stack_size, 2 * 1024 * 1024); |
611 | |
585 #endif | 612 #endif |
586 | 613 |
587 #if !(NGX_WIN32) | 614 #if !(NGX_WIN32) |
588 | 615 |
589 if (ccf->user == (uid_t) NGX_CONF_UNSET_UINT && geteuid() == 0) { | 616 if (ccf->user == (uid_t) NGX_CONF_UNSET_UINT && geteuid() == 0) { |
730 ccf->priority = -ccf->priority; | 757 ccf->priority = -ccf->priority; |
731 } | 758 } |
732 | 759 |
733 return NGX_CONF_OK; | 760 return NGX_CONF_OK; |
734 } | 761 } |
762 | |
763 | |
764 static char * | |
765 ngx_set_cpu_affinity(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
766 { | |
767 #if (NGX_HAVE_SCHED_SETAFFINITY) | |
768 ngx_core_conf_t *ccf = conf; | |
769 | |
770 u_char ch; | |
771 u_long *mask; | |
772 ngx_str_t *value; | |
773 ngx_uint_t i, n; | |
774 | |
775 if (ccf->cpu_affinity) { | |
776 return "is duplicate"; | |
777 } | |
778 | |
779 mask = ngx_palloc(cf->pool, (cf->args->nelts - 1) * sizeof(long)); | |
780 if (mask == NULL) { | |
781 return NGX_CONF_ERROR; | |
782 } | |
783 | |
784 ccf->cpu_affinity_n = cf->args->nelts - 1; | |
785 ccf->cpu_affinity = mask; | |
786 | |
787 value = cf->args->elts; | |
788 | |
789 for (n = 1; n < cf->args->nelts; n++) { | |
790 | |
791 if (value[n].len > 32) { | |
792 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
793 "\"worker_cpu_affinity\" supports up to 32 CPU only"); | |
794 return NGX_CONF_ERROR; | |
795 } | |
796 | |
797 mask[n - 1] = 0; | |
798 | |
799 for (i = 0; i < value[n].len; i++) { | |
800 | |
801 ch = value[n].data[i]; | |
802 | |
803 if (ch == ' ') { | |
804 continue; | |
805 } | |
806 | |
807 mask[n - 1] <<= 1; | |
808 | |
809 if (ch == '0') { | |
810 continue; | |
811 } | |
812 | |
813 if (ch == '1') { | |
814 mask[n - 1] |= 1; | |
815 continue; | |
816 } | |
817 | |
818 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
819 "invalid character \"%c\" in \"worker_cpu_affinity\"", | |
820 ch); | |
821 return NGX_CONF_ERROR ; | |
822 } | |
823 } | |
824 | |
825 #else | |
826 | |
827 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
828 "\"worker_cpu_affinity\" is not supported " | |
829 "on this platform, ignored"); | |
830 #endif | |
831 | |
832 return NGX_CONF_OK; | |
833 } | |
834 | |
835 | |
836 u_long | |
837 ngx_get_cpu_affinity(ngx_uint_t n) | |
838 { | |
839 ngx_core_conf_t *ccf; | |
840 | |
841 ccf = (ngx_core_conf_t *) ngx_get_conf(ngx_cycle->conf_ctx, | |
842 ngx_core_module); | |
843 | |
844 if (ccf->cpu_affinity == NULL) { | |
845 return 0; | |
846 } | |
847 | |
848 if (ccf->cpu_affinity_n > n) { | |
849 return ccf->cpu_affinity[n]; | |
850 } | |
851 | |
852 return ccf->cpu_affinity[ccf->cpu_affinity_n - 1]; | |
853 } |