【问题标题】:Values set in post_config hook not visible in request scope on Apache 2.4post_config 挂钩中设置的值在 Apache 2.4 的请求范围内不可见
【发布时间】: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 中访问 c​​onf->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


    【解决方案1】:

    更新配置数据后是否需要调用 ap_set_module_config()?

    【讨论】:

    • 这是在提出问题而不是提供答案,应该是评论。一旦你有足够的代表,你就可以离开 cmets。
    猜你喜欢
    • 1970-01-01
    • 2020-05-01
    • 1970-01-01
    • 2018-01-04
    • 2011-10-06
    • 1970-01-01
    • 1970-01-01
    • 2015-08-30
    • 1970-01-01
    相关资源
    最近更新 更多