Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 3318:48402deff89a
style fix: lcf > clcf
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 13 Nov 2009 19:59:54 +0000 |
parents | 118169a8ec92 |
children | 42c16d8bddbe |
comparison
equal
deleted
inserted
replaced
3317:dcb0d3658944 | 3318:48402deff89a |
---|---|
2631 | 2631 |
2632 | 2632 |
2633 static char * | 2633 static char * |
2634 ngx_http_core_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 2634 ngx_http_core_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
2635 { | 2635 { |
2636 ngx_http_core_loc_conf_t *lcf = conf; | 2636 ngx_http_core_loc_conf_t *clcf = conf; |
2637 | 2637 |
2638 char *rv; | 2638 char *rv; |
2639 ngx_conf_t save; | 2639 ngx_conf_t save; |
2640 | 2640 |
2641 if (lcf->types == NULL) { | 2641 if (clcf->types == NULL) { |
2642 lcf->types = ngx_array_create(cf->pool, 64, sizeof(ngx_hash_key_t)); | 2642 clcf->types = ngx_array_create(cf->pool, 64, sizeof(ngx_hash_key_t)); |
2643 if (lcf->types == NULL) { | 2643 if (clcf->types == NULL) { |
2644 return NGX_CONF_ERROR; | 2644 return NGX_CONF_ERROR; |
2645 } | 2645 } |
2646 } | 2646 } |
2647 | 2647 |
2648 save = *cf; | 2648 save = *cf; |
2658 | 2658 |
2659 | 2659 |
2660 static char * | 2660 static char * |
2661 ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) | 2661 ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) |
2662 { | 2662 { |
2663 ngx_http_core_loc_conf_t *lcf = conf; | 2663 ngx_http_core_loc_conf_t *clcf = conf; |
2664 | 2664 |
2665 ngx_str_t *value, *content_type, *old, file; | 2665 ngx_str_t *value, *content_type, *old, file; |
2666 ngx_uint_t i, n, hash; | 2666 ngx_uint_t i, n, hash; |
2667 ngx_hash_key_t *type; | 2667 ngx_hash_key_t *type; |
2668 | 2668 |
2689 | 2689 |
2690 for (i = 1; i < cf->args->nelts; i++) { | 2690 for (i = 1; i < cf->args->nelts; i++) { |
2691 | 2691 |
2692 hash = ngx_hash_strlow(value[i].data, value[i].data, value[i].len); | 2692 hash = ngx_hash_strlow(value[i].data, value[i].data, value[i].len); |
2693 | 2693 |
2694 type = lcf->types->elts; | 2694 type = clcf->types->elts; |
2695 for (n = 0; n < lcf->types->nelts; n++) { | 2695 for (n = 0; n < clcf->types->nelts; n++) { |
2696 if (ngx_strcmp(value[i].data, type[n].key.data) == 0) { | 2696 if (ngx_strcmp(value[i].data, type[n].key.data) == 0) { |
2697 old = type[n].value; | 2697 old = type[n].value; |
2698 type[n].value = content_type; | 2698 type[n].value = content_type; |
2699 | 2699 |
2700 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | 2700 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, |
2705 continue; | 2705 continue; |
2706 } | 2706 } |
2707 } | 2707 } |
2708 | 2708 |
2709 | 2709 |
2710 type = ngx_array_push(lcf->types); | 2710 type = ngx_array_push(clcf->types); |
2711 if (type == NULL) { | 2711 if (type == NULL) { |
2712 return NGX_CONF_ERROR; | 2712 return NGX_CONF_ERROR; |
2713 } | 2713 } |
2714 | 2714 |
2715 type->key = value[i]; | 2715 type->key = value[i]; |
2910 | 2910 |
2911 | 2911 |
2912 static void * | 2912 static void * |
2913 ngx_http_core_create_loc_conf(ngx_conf_t *cf) | 2913 ngx_http_core_create_loc_conf(ngx_conf_t *cf) |
2914 { | 2914 { |
2915 ngx_http_core_loc_conf_t *lcf; | 2915 ngx_http_core_loc_conf_t *clcf; |
2916 | 2916 |
2917 lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_loc_conf_t)); | 2917 clcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_loc_conf_t)); |
2918 if (lcf == NULL) { | 2918 if (clcf == NULL) { |
2919 return NULL; | 2919 return NULL; |
2920 } | 2920 } |
2921 | 2921 |
2922 /* | 2922 /* |
2923 * set by ngx_pcalloc(): | 2923 * set by ngx_pcalloc(): |
2924 * | 2924 * |
2925 * lcf->root = { 0, NULL }; | 2925 * clcf->root = { 0, NULL }; |
2926 * lcf->limit_except = 0; | 2926 * clcf->limit_except = 0; |
2927 * lcf->post_action = { 0, NULL }; | 2927 * clcf->post_action = { 0, NULL }; |
2928 * lcf->types = NULL; | 2928 * clcf->types = NULL; |
2929 * lcf->default_type = { 0, NULL }; | 2929 * clcf->default_type = { 0, NULL }; |
2930 * lcf->error_log = NULL; | 2930 * clcf->error_log = NULL; |
2931 * lcf->error_pages = NULL; | 2931 * clcf->error_pages = NULL; |
2932 * lcf->try_files = NULL; | 2932 * clcf->try_files = NULL; |
2933 * lcf->client_body_path = NULL; | 2933 * clcf->client_body_path = NULL; |
2934 * lcf->regex = NULL; | 2934 * clcf->regex = NULL; |
2935 * lcf->exact_match = 0; | 2935 * clcf->exact_match = 0; |
2936 * lcf->auto_redirect = 0; | 2936 * clcf->auto_redirect = 0; |
2937 * lcf->alias = 0; | 2937 * clcf->alias = 0; |
2938 * lcf->gzip_proxied = 0; | 2938 * clcf->gzip_proxied = 0; |
2939 */ | 2939 */ |
2940 | 2940 |
2941 lcf->client_max_body_size = NGX_CONF_UNSET; | 2941 clcf->client_max_body_size = NGX_CONF_UNSET; |
2942 lcf->client_body_buffer_size = NGX_CONF_UNSET_SIZE; | 2942 clcf->client_body_buffer_size = NGX_CONF_UNSET_SIZE; |
2943 lcf->client_body_timeout = NGX_CONF_UNSET_MSEC; | 2943 clcf->client_body_timeout = NGX_CONF_UNSET_MSEC; |
2944 lcf->satisfy = NGX_CONF_UNSET_UINT; | 2944 clcf->satisfy = NGX_CONF_UNSET_UINT; |
2945 lcf->if_modified_since = NGX_CONF_UNSET_UINT; | 2945 clcf->if_modified_since = NGX_CONF_UNSET_UINT; |
2946 lcf->client_body_in_file_only = NGX_CONF_UNSET_UINT; | 2946 clcf->client_body_in_file_only = NGX_CONF_UNSET_UINT; |
2947 lcf->client_body_in_single_buffer = NGX_CONF_UNSET; | 2947 clcf->client_body_in_single_buffer = NGX_CONF_UNSET; |
2948 lcf->internal = NGX_CONF_UNSET; | 2948 clcf->internal = NGX_CONF_UNSET; |
2949 lcf->sendfile = NGX_CONF_UNSET; | 2949 clcf->sendfile = NGX_CONF_UNSET; |
2950 lcf->sendfile_max_chunk = NGX_CONF_UNSET_SIZE; | 2950 clcf->sendfile_max_chunk = NGX_CONF_UNSET_SIZE; |
2951 #if (NGX_HAVE_FILE_AIO) | 2951 #if (NGX_HAVE_FILE_AIO) |
2952 lcf->aio = NGX_CONF_UNSET; | 2952 clcf->aio = NGX_CONF_UNSET; |
2953 #endif | 2953 #endif |
2954 lcf->read_ahead = NGX_CONF_UNSET_SIZE; | 2954 clcf->read_ahead = NGX_CONF_UNSET_SIZE; |
2955 lcf->directio = NGX_CONF_UNSET; | 2955 clcf->directio = NGX_CONF_UNSET; |
2956 lcf->directio_alignment = NGX_CONF_UNSET; | 2956 clcf->directio_alignment = NGX_CONF_UNSET; |
2957 lcf->tcp_nopush = NGX_CONF_UNSET; | 2957 clcf->tcp_nopush = NGX_CONF_UNSET; |
2958 lcf->tcp_nodelay = NGX_CONF_UNSET; | 2958 clcf->tcp_nodelay = NGX_CONF_UNSET; |
2959 lcf->send_timeout = NGX_CONF_UNSET_MSEC; | 2959 clcf->send_timeout = NGX_CONF_UNSET_MSEC; |
2960 lcf->send_lowat = NGX_CONF_UNSET_SIZE; | 2960 clcf->send_lowat = NGX_CONF_UNSET_SIZE; |
2961 lcf->postpone_output = NGX_CONF_UNSET_SIZE; | 2961 clcf->postpone_output = NGX_CONF_UNSET_SIZE; |
2962 lcf->limit_rate = NGX_CONF_UNSET_SIZE; | 2962 clcf->limit_rate = NGX_CONF_UNSET_SIZE; |
2963 lcf->limit_rate_after = NGX_CONF_UNSET_SIZE; | 2963 clcf->limit_rate_after = NGX_CONF_UNSET_SIZE; |
2964 lcf->keepalive_timeout = NGX_CONF_UNSET_MSEC; | 2964 clcf->keepalive_timeout = NGX_CONF_UNSET_MSEC; |
2965 lcf->keepalive_header = NGX_CONF_UNSET; | 2965 clcf->keepalive_header = NGX_CONF_UNSET; |
2966 lcf->keepalive_requests = NGX_CONF_UNSET_UINT; | 2966 clcf->keepalive_requests = NGX_CONF_UNSET_UINT; |
2967 lcf->lingering_time = NGX_CONF_UNSET_MSEC; | 2967 clcf->lingering_time = NGX_CONF_UNSET_MSEC; |
2968 lcf->lingering_timeout = NGX_CONF_UNSET_MSEC; | 2968 clcf->lingering_timeout = NGX_CONF_UNSET_MSEC; |
2969 lcf->resolver_timeout = NGX_CONF_UNSET_MSEC; | 2969 clcf->resolver_timeout = NGX_CONF_UNSET_MSEC; |
2970 lcf->reset_timedout_connection = NGX_CONF_UNSET; | 2970 clcf->reset_timedout_connection = NGX_CONF_UNSET; |
2971 lcf->server_name_in_redirect = NGX_CONF_UNSET; | 2971 clcf->server_name_in_redirect = NGX_CONF_UNSET; |
2972 lcf->port_in_redirect = NGX_CONF_UNSET; | 2972 clcf->port_in_redirect = NGX_CONF_UNSET; |
2973 lcf->msie_padding = NGX_CONF_UNSET; | 2973 clcf->msie_padding = NGX_CONF_UNSET; |
2974 lcf->msie_refresh = NGX_CONF_UNSET; | 2974 clcf->msie_refresh = NGX_CONF_UNSET; |
2975 lcf->log_not_found = NGX_CONF_UNSET; | 2975 clcf->log_not_found = NGX_CONF_UNSET; |
2976 lcf->log_subrequest = NGX_CONF_UNSET; | 2976 clcf->log_subrequest = NGX_CONF_UNSET; |
2977 lcf->recursive_error_pages = NGX_CONF_UNSET; | 2977 clcf->recursive_error_pages = NGX_CONF_UNSET; |
2978 lcf->server_tokens = NGX_CONF_UNSET; | 2978 clcf->server_tokens = NGX_CONF_UNSET; |
2979 lcf->types_hash_max_size = NGX_CONF_UNSET_UINT; | 2979 clcf->types_hash_max_size = NGX_CONF_UNSET_UINT; |
2980 lcf->types_hash_bucket_size = NGX_CONF_UNSET_UINT; | 2980 clcf->types_hash_bucket_size = NGX_CONF_UNSET_UINT; |
2981 | 2981 |
2982 lcf->open_file_cache = NGX_CONF_UNSET_PTR; | 2982 clcf->open_file_cache = NGX_CONF_UNSET_PTR; |
2983 lcf->open_file_cache_valid = NGX_CONF_UNSET; | 2983 clcf->open_file_cache_valid = NGX_CONF_UNSET; |
2984 lcf->open_file_cache_min_uses = NGX_CONF_UNSET_UINT; | 2984 clcf->open_file_cache_min_uses = NGX_CONF_UNSET_UINT; |
2985 lcf->open_file_cache_errors = NGX_CONF_UNSET; | 2985 clcf->open_file_cache_errors = NGX_CONF_UNSET; |
2986 lcf->open_file_cache_events = NGX_CONF_UNSET; | 2986 clcf->open_file_cache_events = NGX_CONF_UNSET; |
2987 | 2987 |
2988 #if (NGX_HTTP_GZIP) | 2988 #if (NGX_HTTP_GZIP) |
2989 lcf->gzip_vary = NGX_CONF_UNSET; | 2989 clcf->gzip_vary = NGX_CONF_UNSET; |
2990 lcf->gzip_http_version = NGX_CONF_UNSET_UINT; | 2990 clcf->gzip_http_version = NGX_CONF_UNSET_UINT; |
2991 #if (NGX_PCRE) | 2991 #if (NGX_PCRE) |
2992 lcf->gzip_disable = NGX_CONF_UNSET_PTR; | 2992 clcf->gzip_disable = NGX_CONF_UNSET_PTR; |
2993 lcf->gzip_disable_msie6 = 3; | 2993 clcf->gzip_disable_msie6 = 3; |
2994 #endif | 2994 #endif |
2995 #endif | 2995 #endif |
2996 | 2996 |
2997 return lcf; | 2997 return clcf; |
2998 } | 2998 } |
2999 | 2999 |
3000 | 3000 |
3001 static ngx_str_t ngx_http_core_text_html_type = ngx_string("text/html"); | 3001 static ngx_str_t ngx_http_core_text_html_type = ngx_string("text/html"); |
3002 static ngx_str_t ngx_http_core_image_gif_type = ngx_string("image/gif"); | 3002 static ngx_str_t ngx_http_core_image_gif_type = ngx_string("image/gif"); |
3574 | 3574 |
3575 | 3575 |
3576 static char * | 3576 static char * |
3577 ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 3577 ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
3578 { | 3578 { |
3579 ngx_http_core_loc_conf_t *lcf = conf; | 3579 ngx_http_core_loc_conf_t *clcf = conf; |
3580 | 3580 |
3581 ngx_str_t *value; | 3581 ngx_str_t *value; |
3582 ngx_uint_t alias, n; | 3582 ngx_uint_t alias, n; |
3583 ngx_http_script_compile_t sc; | 3583 ngx_http_script_compile_t sc; |
3584 | 3584 |
3585 alias = (cmd->name.len == sizeof("alias") - 1) ? 1 : 0; | 3585 alias = (cmd->name.len == sizeof("alias") - 1) ? 1 : 0; |
3586 | 3586 |
3587 if (lcf->root.data) { | 3587 if (clcf->root.data) { |
3588 | 3588 |
3589 /* the (ngx_uint_t) cast is required by gcc 2.7.2.3 */ | 3589 /* the (ngx_uint_t) cast is required by gcc 2.7.2.3 */ |
3590 | 3590 |
3591 if ((ngx_uint_t) lcf->alias == alias) { | 3591 if ((ngx_uint_t) clcf->alias == alias) { |
3592 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 3592 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3593 "\"%V\" directive is duplicate", | 3593 "\"%V\" directive is duplicate", |
3594 &cmd->name); | 3594 &cmd->name); |
3595 } else { | 3595 } else { |
3596 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 3596 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3597 "\"%V\" directive is duplicate, " | 3597 "\"%V\" directive is duplicate, " |
3598 "\"%s\" directive is specified before", | 3598 "\"%s\" directive is specified before", |
3599 &cmd->name, lcf->alias ? "alias" : "root"); | 3599 &cmd->name, clcf->alias ? "alias" : "root"); |
3600 } | 3600 } |
3601 | 3601 |
3602 return NGX_CONF_ERROR; | 3602 return NGX_CONF_ERROR; |
3603 } | 3603 } |
3604 | 3604 |
3605 if (lcf->named && alias) { | 3605 if (clcf->named && alias) { |
3606 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 3606 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3607 "the \"alias\" directive may not be used " | 3607 "the \"alias\" directive may not be used " |
3608 "inside named location"); | 3608 "inside named location"); |
3609 | 3609 |
3610 return NGX_CONF_ERROR; | 3610 return NGX_CONF_ERROR; |
3632 &cmd->name); | 3632 &cmd->name); |
3633 | 3633 |
3634 return NGX_CONF_ERROR; | 3634 return NGX_CONF_ERROR; |
3635 } | 3635 } |
3636 | 3636 |
3637 lcf->alias = alias; | 3637 clcf->alias = alias; |
3638 lcf->root = value[1]; | 3638 clcf->root = value[1]; |
3639 | 3639 |
3640 if (!alias && lcf->root.data[lcf->root.len - 1] == '/') { | 3640 if (!alias && clcf->root.data[clcf->root.len - 1] == '/') { |
3641 lcf->root.len--; | 3641 clcf->root.len--; |
3642 } | 3642 } |
3643 | 3643 |
3644 if (lcf->root.data[0] != '$') { | 3644 if (clcf->root.data[0] != '$') { |
3645 if (ngx_conf_full_name(cf->cycle, &lcf->root, 0) != NGX_OK) { | 3645 if (ngx_conf_full_name(cf->cycle, &clcf->root, 0) != NGX_OK) { |
3646 return NGX_CONF_ERROR; | 3646 return NGX_CONF_ERROR; |
3647 } | 3647 } |
3648 } | 3648 } |
3649 | 3649 |
3650 n = ngx_http_script_variables_count(&lcf->root); | 3650 n = ngx_http_script_variables_count(&clcf->root); |
3651 | 3651 |
3652 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | 3652 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); |
3653 | 3653 |
3654 if (n) { | 3654 if (n) { |
3655 sc.cf = cf; | 3655 sc.cf = cf; |
3656 sc.source = &lcf->root; | 3656 sc.source = &clcf->root; |
3657 sc.lengths = &lcf->root_lengths; | 3657 sc.lengths = &clcf->root_lengths; |
3658 sc.values = &lcf->root_values; | 3658 sc.values = &clcf->root_values; |
3659 sc.variables = n; | 3659 sc.variables = n; |
3660 sc.complete_lengths = 1; | 3660 sc.complete_lengths = 1; |
3661 sc.complete_values = 1; | 3661 sc.complete_values = 1; |
3662 | 3662 |
3663 if (ngx_http_script_compile(&sc) != NGX_OK) { | 3663 if (ngx_http_script_compile(&sc) != NGX_OK) { |
3665 } | 3665 } |
3666 } | 3666 } |
3667 | 3667 |
3668 #if (NGX_PCRE) | 3668 #if (NGX_PCRE) |
3669 | 3669 |
3670 if (alias && lcf->regex | 3670 if (alias && clcf->regex |
3671 && (ngx_regex_capture_count(lcf->regex) <= 0 || sc.ncaptures == 0)) | 3671 && (ngx_regex_capture_count(clcf->regex) <= 0 || sc.ncaptures == 0)) |
3672 { | 3672 { |
3673 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 3673 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3674 "the \"alias\" directive must use captures " | 3674 "the \"alias\" directive must use captures " |
3675 "inside location given by regular expression"); | 3675 "inside location given by regular expression"); |
3676 | 3676 |
3828 | 3828 |
3829 | 3829 |
3830 static char * | 3830 static char * |
3831 ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 3831 ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
3832 { | 3832 { |
3833 ngx_http_core_loc_conf_t *lcf = conf; | 3833 ngx_http_core_loc_conf_t *clcf = conf; |
3834 | 3834 |
3835 u_char *p; | 3835 u_char *p; |
3836 ngx_int_t overwrite; | 3836 ngx_int_t overwrite; |
3837 ngx_str_t *value, uri, args; | 3837 ngx_str_t *value, uri, args; |
3838 ngx_uint_t i, n; | 3838 ngx_uint_t i, n; |
3839 ngx_http_err_page_t *err; | 3839 ngx_http_err_page_t *err; |
3840 ngx_http_complex_value_t cv; | 3840 ngx_http_complex_value_t cv; |
3841 ngx_http_compile_complex_value_t ccv; | 3841 ngx_http_compile_complex_value_t ccv; |
3842 | 3842 |
3843 if (lcf->error_pages == NULL) { | 3843 if (clcf->error_pages == NULL) { |
3844 lcf->error_pages = ngx_array_create(cf->pool, 4, | 3844 clcf->error_pages = ngx_array_create(cf->pool, 4, |
3845 sizeof(ngx_http_err_page_t)); | 3845 sizeof(ngx_http_err_page_t)); |
3846 if (lcf->error_pages == NULL) { | 3846 if (clcf->error_pages == NULL) { |
3847 return NGX_CONF_ERROR; | 3847 return NGX_CONF_ERROR; |
3848 } | 3848 } |
3849 } | 3849 } |
3850 | 3850 |
3851 value = cf->args->elts; | 3851 value = cf->args->elts; |
3905 args.data = p; | 3905 args.data = p; |
3906 } | 3906 } |
3907 } | 3907 } |
3908 | 3908 |
3909 for (i = 1; i < cf->args->nelts - n; i++) { | 3909 for (i = 1; i < cf->args->nelts - n; i++) { |
3910 err = ngx_array_push(lcf->error_pages); | 3910 err = ngx_array_push(clcf->error_pages); |
3911 if (err == NULL) { | 3911 if (err == NULL) { |
3912 return NGX_CONF_ERROR; | 3912 return NGX_CONF_ERROR; |
3913 } | 3913 } |
3914 | 3914 |
3915 err->status = ngx_atoi(value[i].data, value[i].len); | 3915 err->status = ngx_atoi(value[i].data, value[i].len); |
4033 | 4033 |
4034 | 4034 |
4035 static char * | 4035 static char * |
4036 ngx_http_core_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 4036 ngx_http_core_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
4037 { | 4037 { |
4038 ngx_http_core_loc_conf_t *lcf = conf; | 4038 ngx_http_core_loc_conf_t *clcf = conf; |
4039 | 4039 |
4040 time_t inactive; | 4040 time_t inactive; |
4041 ngx_str_t *value, s; | 4041 ngx_str_t *value, s; |
4042 ngx_int_t max; | 4042 ngx_int_t max; |
4043 ngx_uint_t i; | 4043 ngx_uint_t i; |
4044 | 4044 |
4045 if (lcf->open_file_cache != NGX_CONF_UNSET_PTR) { | 4045 if (clcf->open_file_cache != NGX_CONF_UNSET_PTR) { |
4046 return "is duplicate"; | 4046 return "is duplicate"; |
4047 } | 4047 } |
4048 | 4048 |
4049 value = cf->args->elts; | 4049 value = cf->args->elts; |
4050 | 4050 |
4076 continue; | 4076 continue; |
4077 } | 4077 } |
4078 | 4078 |
4079 if (ngx_strcmp(value[i].data, "off") == 0) { | 4079 if (ngx_strcmp(value[i].data, "off") == 0) { |
4080 | 4080 |
4081 lcf->open_file_cache = NULL; | 4081 clcf->open_file_cache = NULL; |
4082 | 4082 |
4083 continue; | 4083 continue; |
4084 } | 4084 } |
4085 | 4085 |
4086 failed: | 4086 failed: |
4089 "invalid \"open_file_cache\" parameter \"%V\"", | 4089 "invalid \"open_file_cache\" parameter \"%V\"", |
4090 &value[i]); | 4090 &value[i]); |
4091 return NGX_CONF_ERROR; | 4091 return NGX_CONF_ERROR; |
4092 } | 4092 } |
4093 | 4093 |
4094 if (lcf->open_file_cache == NULL) { | 4094 if (clcf->open_file_cache == NULL) { |
4095 return NGX_CONF_OK; | 4095 return NGX_CONF_OK; |
4096 } | 4096 } |
4097 | 4097 |
4098 if (max == 0) { | 4098 if (max == 0) { |
4099 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 4099 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
4100 "\"open_file_cache\" must have \"max\" parameter"); | 4100 "\"open_file_cache\" must have \"max\" parameter"); |
4101 return NGX_CONF_ERROR; | 4101 return NGX_CONF_ERROR; |
4102 } | 4102 } |
4103 | 4103 |
4104 lcf->open_file_cache = ngx_open_file_cache_init(cf->pool, max, inactive); | 4104 clcf->open_file_cache = ngx_open_file_cache_init(cf->pool, max, inactive); |
4105 if (lcf->open_file_cache) { | 4105 if (clcf->open_file_cache) { |
4106 return NGX_CONF_OK; | 4106 return NGX_CONF_OK; |
4107 } | 4107 } |
4108 | 4108 |
4109 return NGX_CONF_ERROR; | 4109 return NGX_CONF_ERROR; |
4110 } | 4110 } |
4111 | 4111 |
4112 | 4112 |
4113 static char * | 4113 static char * |
4114 ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 4114 ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
4115 { | 4115 { |
4116 ngx_http_core_loc_conf_t *lcf = conf; | 4116 ngx_http_core_loc_conf_t *clcf = conf; |
4117 | 4117 |
4118 ngx_str_t *value; | 4118 ngx_str_t *value; |
4119 | 4119 |
4120 if (lcf->error_log) { | 4120 if (clcf->error_log) { |
4121 return "is duplicate"; | 4121 return "is duplicate"; |
4122 } | 4122 } |
4123 | 4123 |
4124 value = cf->args->elts; | 4124 value = cf->args->elts; |
4125 | 4125 |
4126 lcf->error_log = ngx_log_create(cf->cycle, &value[1]); | 4126 clcf->error_log = ngx_log_create(cf->cycle, &value[1]); |
4127 if (lcf->error_log == NULL) { | 4127 if (clcf->error_log == NULL) { |
4128 return NGX_CONF_ERROR; | 4128 return NGX_CONF_ERROR; |
4129 } | 4129 } |
4130 | 4130 |
4131 if (cf->args->nelts == 2) { | 4131 if (cf->args->nelts == 2) { |
4132 lcf->error_log->log_level = NGX_LOG_ERR; | 4132 clcf->error_log->log_level = NGX_LOG_ERR; |
4133 return NGX_CONF_OK; | 4133 return NGX_CONF_OK; |
4134 } | 4134 } |
4135 | 4135 |
4136 return ngx_log_set_levels(cf, lcf->error_log); | 4136 return ngx_log_set_levels(cf, clcf->error_log); |
4137 } | 4137 } |
4138 | 4138 |
4139 | 4139 |
4140 static char * | 4140 static char * |
4141 ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 4141 ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
4142 { | 4142 { |
4143 ngx_http_core_loc_conf_t *lcf = conf; | 4143 ngx_http_core_loc_conf_t *clcf = conf; |
4144 | 4144 |
4145 ngx_str_t *value; | 4145 ngx_str_t *value; |
4146 | 4146 |
4147 if (lcf->keepalive_timeout != NGX_CONF_UNSET_MSEC) { | 4147 if (clcf->keepalive_timeout != NGX_CONF_UNSET_MSEC) { |
4148 return "is duplicate"; | 4148 return "is duplicate"; |
4149 } | 4149 } |
4150 | 4150 |
4151 value = cf->args->elts; | 4151 value = cf->args->elts; |
4152 | 4152 |
4153 lcf->keepalive_timeout = ngx_parse_time(&value[1], 0); | 4153 clcf->keepalive_timeout = ngx_parse_time(&value[1], 0); |
4154 | 4154 |
4155 if (lcf->keepalive_timeout == (ngx_msec_t) NGX_ERROR) { | 4155 if (clcf->keepalive_timeout == (ngx_msec_t) NGX_ERROR) { |
4156 return "invalid value"; | 4156 return "invalid value"; |
4157 } | 4157 } |
4158 | 4158 |
4159 if (lcf->keepalive_timeout == (ngx_msec_t) NGX_PARSE_LARGE_TIME) { | 4159 if (clcf->keepalive_timeout == (ngx_msec_t) NGX_PARSE_LARGE_TIME) { |
4160 return "value must be less than 597 hours"; | 4160 return "value must be less than 597 hours"; |
4161 } | 4161 } |
4162 | 4162 |
4163 if (cf->args->nelts == 2) { | 4163 if (cf->args->nelts == 2) { |
4164 return NGX_CONF_OK; | 4164 return NGX_CONF_OK; |
4165 } | 4165 } |
4166 | 4166 |
4167 lcf->keepalive_header = ngx_parse_time(&value[2], 1); | 4167 clcf->keepalive_header = ngx_parse_time(&value[2], 1); |
4168 | 4168 |
4169 if (lcf->keepalive_header == NGX_ERROR) { | 4169 if (clcf->keepalive_header == NGX_ERROR) { |
4170 return "invalid value"; | 4170 return "invalid value"; |
4171 } | 4171 } |
4172 | 4172 |
4173 if (lcf->keepalive_header == NGX_PARSE_LARGE_TIME) { | 4173 if (clcf->keepalive_header == NGX_PARSE_LARGE_TIME) { |
4174 return "value must be less than 68 years"; | 4174 return "value must be less than 68 years"; |
4175 } | 4175 } |
4176 | 4176 |
4177 return NGX_CONF_OK; | 4177 return NGX_CONF_OK; |
4178 } | 4178 } |
4179 | 4179 |
4180 | 4180 |
4181 static char * | 4181 static char * |
4182 ngx_http_core_internal(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 4182 ngx_http_core_internal(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
4183 { | 4183 { |
4184 ngx_http_core_loc_conf_t *lcf = conf; | 4184 ngx_http_core_loc_conf_t *clcf = conf; |
4185 | 4185 |
4186 if (lcf->internal != NGX_CONF_UNSET) { | 4186 if (clcf->internal != NGX_CONF_UNSET) { |
4187 return "is duplicate"; | 4187 return "is duplicate"; |
4188 } | 4188 } |
4189 | 4189 |
4190 lcf->internal = 1; | 4190 clcf->internal = 1; |
4191 | 4191 |
4192 return NGX_CONF_OK; | 4192 return NGX_CONF_OK; |
4193 } | 4193 } |
4194 | 4194 |
4195 | 4195 |