Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 3853:57d2533f98b3
move setting conf->server_name in merge phase
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 20 Jan 2011 15:15:50 +0000 |
parents | 005d5cf5b403 |
children | 6c5f2ba0397d |
comparison
equal
deleted
inserted
replaced
3852:3f04918aefe5 | 3853:57d2533f98b3 |
---|---|
2988 ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) | 2988 ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) |
2989 { | 2989 { |
2990 ngx_http_core_srv_conf_t *prev = parent; | 2990 ngx_http_core_srv_conf_t *prev = parent; |
2991 ngx_http_core_srv_conf_t *conf = child; | 2991 ngx_http_core_srv_conf_t *conf = child; |
2992 | 2992 |
2993 ngx_str_t name; | |
2993 ngx_http_server_name_t *sn; | 2994 ngx_http_server_name_t *sn; |
2994 | 2995 |
2995 /* TODO: it does not merge, it inits only */ | 2996 /* TODO: it does not merge, it inits only */ |
2996 | 2997 |
2997 ngx_conf_merge_size_value(conf->connection_pool_size, | 2998 ngx_conf_merge_size_value(conf->connection_pool_size, |
3019 ngx_conf_merge_value(conf->merge_slashes, prev->merge_slashes, 1); | 3020 ngx_conf_merge_value(conf->merge_slashes, prev->merge_slashes, 1); |
3020 | 3021 |
3021 ngx_conf_merge_value(conf->underscores_in_headers, | 3022 ngx_conf_merge_value(conf->underscores_in_headers, |
3022 prev->underscores_in_headers, 0); | 3023 prev->underscores_in_headers, 0); |
3023 | 3024 |
3024 if (conf->server_name.data == NULL) { | 3025 if (conf->server_names.nelts == 0) { |
3025 ngx_str_set(&conf->server_name, ""); | 3026 /* the array has 4 empty preallocated elements, so push can not fail */ |
3026 | |
3027 sn = ngx_array_push(&conf->server_names); | 3027 sn = ngx_array_push(&conf->server_names); |
3028 if (sn == NULL) { | |
3029 return NGX_CONF_ERROR; | |
3030 } | |
3031 | |
3032 #if (NGX_PCRE) | 3028 #if (NGX_PCRE) |
3033 sn->regex = NULL; | 3029 sn->regex = NULL; |
3034 #endif | 3030 #endif |
3035 sn->server = conf; | 3031 sn->server = conf; |
3036 ngx_str_set(&sn->name, ""); | 3032 ngx_str_set(&sn->name, ""); |
3033 } | |
3034 | |
3035 sn = conf->server_names.elts; | |
3036 name = sn[0].name; | |
3037 | |
3038 #if (NGX_PCRE) | |
3039 if (sn->regex) { | |
3040 name.len++; | |
3041 name.data--; | |
3042 } else | |
3043 #endif | |
3044 | |
3045 if (name.data[0] == '.') { | |
3046 name.len--; | |
3047 name.data++; | |
3048 } | |
3049 | |
3050 conf->server_name.len = name.len; | |
3051 conf->server_name.data = ngx_pstrdup(cf->pool, &name); | |
3052 if (conf->server_name.data == NULL) { | |
3053 return NGX_CONF_ERROR; | |
3037 } | 3054 } |
3038 | 3055 |
3039 return NGX_CONF_OK; | 3056 return NGX_CONF_OK; |
3040 } | 3057 } |
3041 | 3058 |
3623 ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 3640 ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
3624 { | 3641 { |
3625 ngx_http_core_srv_conf_t *cscf = conf; | 3642 ngx_http_core_srv_conf_t *cscf = conf; |
3626 | 3643 |
3627 u_char ch; | 3644 u_char ch; |
3628 ngx_str_t *value, name; | 3645 ngx_str_t *value; |
3629 ngx_uint_t i; | 3646 ngx_uint_t i; |
3630 ngx_http_server_name_t *sn; | 3647 ngx_http_server_name_t *sn; |
3631 | 3648 |
3632 value = cf->args->elts; | 3649 value = cf->args->elts; |
3633 | |
3634 ch = value[1].data[0]; | |
3635 | |
3636 if (cscf->server_name.data == NULL) { | |
3637 name = value[1]; | |
3638 | |
3639 if (ch == '.') { | |
3640 name.len--; | |
3641 name.data++; | |
3642 } | |
3643 | |
3644 cscf->server_name.len = name.len; | |
3645 cscf->server_name.data = ngx_pstrdup(cf->pool, &name); | |
3646 if (cscf->server_name.data == NULL) { | |
3647 return NGX_CONF_ERROR; | |
3648 } | |
3649 } | |
3650 | 3650 |
3651 for (i = 1; i < cf->args->nelts; i++) { | 3651 for (i = 1; i < cf->args->nelts; i++) { |
3652 | 3652 |
3653 ch = value[i].data[0]; | 3653 ch = value[i].data[0]; |
3654 | 3654 |