Hi
I am writing an Apache module, I wanna setup some configure variable in the
module via a http request. The variable saved into a apr_hash_t in my own
module configure. But in the next request (the fixup handler), the one with
saved into the apr_hash_t is disappeared. I don't know why, is the memory
pool usage issue?
Thanks.
The sample code likes
1, My own module configureation
typedef struct {
apr_hash_t *var_hash;
} my_own_cfg_t;
2, Initial the configure in the creation handler
static void *create_antibot_cfg(apr_pool_t *p, server_rec *s) {
my_own_cfg_t *cfg;
cfg = (my_own_cfg_t *) apr_pcalloc(p, sizeof(my_own_cfg_t));
cfg->var_hash = apr_hash_make(p);
return (void *) cfg;
}
3, create var in request handler
...
var_t *var = apr_palloc(r->pool, sizeof(var_t));
apr_hash_set(cfg->var_hash, var->key, APR_HASH_KEY_STRING, var);
/* apr_hash_count(cfg->black_hash)); */ /* Shows 1 */
...
4, read the var_hash in another request
/* apr_hash_count(cfg->black_hash)); */ /* Always shows 0 */
--
Weiming Yin