【发布时间】:2016-04-12 15:01:11
【问题描述】:
知道为什么我在模块的 post_config 挂钩中设置的配置值在我的 rewrite_mapfunc 中不可见。
这是我的代码 sn-p:
/** post_config*/
static int post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) {
hs_mod_cfg_t *mod_conf = ap_get_module_config(s->module_config, &my_module);
hs_conf *conf = mod_conf->hs_config;
int thread_count;
ap_mpm_query(AP_MPMQ_MAX_THREADS, &thread_count);
conf->nudge_url = apr_pstrcat(pconf, conf->service_url, "/", HS_API_VERSION, "/", HS_API_NUDGE_PATH, NULL);
return OK;}
然后,当我想在我的 rewrite_mapfunc 中访问 conf->nudge_url 时,这个值为 NULL。请注意,它在 post_config 中已正确设置,我从不重写它。
这里是 rewrite_mapfunc 以及我获取配置的方式。
static char *hailstorm_rewrite_mapfunc(request_rec *r, char *data) {
hs_mod_cfg_t *mod_conf = ap_get_module_config(r->server->module_config, &hailstorm_module);
hs_conf *hs_conf = mod_conf->hs_config;
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "URL= %s", hs_conf->nudge_url);
return HS_MOD_OPEN;}
当我打印 URL 时,即使我之前设置了它,我总是得到 NULL。 hs_conf 中的其他值(我设置为默认值)都具有有效值。
知道我错过了什么或做错了什么。
【问题讨论】:
标签: apache apache-modules