Mercurial > hg > nginx
comparison src/http/ngx_http_variables.c @ 4641:045bb3ef3ffc
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.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 17 May 2012 18:10:34 +0000 |
parents | 67653855682e |
children | 956edecaedeb dad38cdaf496 |
comparison
equal
deleted
inserted
replaced
4640:07f028df3879 | 4641:045bb3ef3ffc |
---|---|
2014 | 2014 |
2015 ngx_int_t | 2015 ngx_int_t |
2016 ngx_http_variables_add_core_vars(ngx_conf_t *cf) | 2016 ngx_http_variables_add_core_vars(ngx_conf_t *cf) |
2017 { | 2017 { |
2018 ngx_int_t rc; | 2018 ngx_int_t rc; |
2019 ngx_http_variable_t *v; | 2019 ngx_http_variable_t *cv, *v; |
2020 ngx_http_core_main_conf_t *cmcf; | 2020 ngx_http_core_main_conf_t *cmcf; |
2021 | 2021 |
2022 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); | 2022 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); |
2023 | 2023 |
2024 cmcf->variables_keys = ngx_pcalloc(cf->temp_pool, | 2024 cmcf->variables_keys = ngx_pcalloc(cf->temp_pool, |
2034 != NGX_OK) | 2034 != NGX_OK) |
2035 { | 2035 { |
2036 return NGX_ERROR; | 2036 return NGX_ERROR; |
2037 } | 2037 } |
2038 | 2038 |
2039 for (v = ngx_http_core_variables; v->name.len; v++) { | 2039 for (cv = ngx_http_core_variables; cv->name.len; cv++) { |
2040 v = ngx_palloc(cf->pool, sizeof(ngx_http_variable_t)); | |
2041 if (v == NULL) { | |
2042 return NGX_ERROR; | |
2043 } | |
2044 | |
2045 *v = *cv; | |
2046 | |
2040 rc = ngx_hash_add_key(cmcf->variables_keys, &v->name, v, | 2047 rc = ngx_hash_add_key(cmcf->variables_keys, &v->name, v, |
2041 NGX_HASH_READONLY_KEY); | 2048 NGX_HASH_READONLY_KEY); |
2042 | 2049 |
2043 if (rc == NGX_OK) { | 2050 if (rc == NGX_OK) { |
2044 continue; | 2051 continue; |