Merge of r4642:
Fixed core variables dynamic access after reconfiguration.
If variable was indexed in previous configuration but not in current
one, the NGX_HTTP_VAR_INDEXED flag was left set and confused
ngx_http_get_variable().
Patch by Yichun Zhang (agentzh), slightly modified.
Maxim Dounin
10 years ago
2015 | 2015 | ngx_http_variables_add_core_vars(ngx_conf_t *cf) |
2016 | 2016 | { |
2017 | 2017 | ngx_int_t rc; |
2018 | ngx_http_variable_t *v; | |
2018 | ngx_http_variable_t *cv, *v; | |
2019 | 2019 | ngx_http_core_main_conf_t *cmcf; |
2020 | 2020 | |
2021 | 2021 | cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); |
2035 | 2035 | return NGX_ERROR; |
2036 | 2036 | } |
2037 | 2037 | |
2038 | for (v = ngx_http_core_variables; v->name.len; v++) { | |
2038 | for (cv = ngx_http_core_variables; cv->name.len; cv++) { | |
2039 | v = ngx_palloc(cf->pool, sizeof(ngx_http_variable_t)); | |
2040 | if (v == NULL) { | |
2041 | return NGX_ERROR; | |
2042 | } | |
2043 | ||
2044 | *v = *cv; | |
2045 | ||
2039 | 2046 | rc = ngx_hash_add_key(cmcf->variables_keys, &v->name, v, |
2040 | 2047 | NGX_HASH_READONLY_KEY); |
2041 | 2048 |