Klaus Demo nginx / cfc5c25
move setting conf->server_name in merge phase Igor Sysoev 9 years ago
1 changed file(s) with 25 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
29892989 ngx_http_core_srv_conf_t *prev = parent;
29902990 ngx_http_core_srv_conf_t *conf = child;
29912991
2992 ngx_str_t name;
29922993 ngx_http_server_name_t *sn;
29932994
29942995 /* TODO: it does not merge, it inits only */
30203021 ngx_conf_merge_value(conf->underscores_in_headers,
30213022 prev->underscores_in_headers, 0);
30223023
3023 if (conf->server_name.data == NULL) {
3024 ngx_str_set(&conf->server_name, "");
3025
3024 if (conf->server_names.nelts == 0) {
3025 /* the array has 4 empty preallocated elements, so push can not fail */
30263026 sn = ngx_array_push(&conf->server_names);
3027 if (sn == NULL) {
3028 return NGX_CONF_ERROR;
3029 }
3030
30313027 #if (NGX_PCRE)
30323028 sn->regex = NULL;
30333029 #endif
30343030 sn->server = conf;
30353031 ngx_str_set(&sn->name, "");
3032 }
3033
3034 sn = conf->server_names.elts;
3035 name = sn[0].name;
3036
3037 #if (NGX_PCRE)
3038 if (sn->regex) {
3039 name.len++;
3040 name.data--;
3041 } else
3042 #endif
3043
3044 if (name.data[0] == '.') {
3045 name.len--;
3046 name.data++;
3047 }
3048
3049 conf->server_name.len = name.len;
3050 conf->server_name.data = ngx_pstrdup(cf->pool, &name);
3051 if (conf->server_name.data == NULL) {
3052 return NGX_CONF_ERROR;
30363053 }
30373054
30383055 return NGX_CONF_OK;
36243641 ngx_http_core_srv_conf_t *cscf = conf;
36253642
36263643 u_char ch;
3627 ngx_str_t *value, name;
3644 ngx_str_t *value;
36283645 ngx_uint_t i;
36293646 ngx_http_server_name_t *sn;
36303647
36313648 value = cf->args->elts;
3632
3633 ch = value[1].data[0];
3634
3635 if (cscf->server_name.data == NULL) {
3636 name = value[1];
3637
3638 if (ch == '.') {
3639 name.len--;
3640 name.data++;
3641 }
3642
3643 cscf->server_name.len = name.len;
3644 cscf->server_name.data = ngx_pstrdup(cf->pool, &name);
3645 if (cscf->server_name.data == NULL) {
3646 return NGX_CONF_ERROR;
3647 }
3648 }
36493649
36503650 for (i = 1; i < cf->args->nelts; i++) {
36513651