[module dev] PCRE compiled code lost at reload

MAGNIEN, Thierry thierry.magnien at sfr.com
Wed Jun 22 15:03:10 UTC 2016

OK, this clears up things.

Thanks a lot!
De : nginx-devel [nginx-devel-bounces at nginx.org] de la part de Maxim Dounin [mdounin at mdounin.ru]
Envoyé : mercredi 22 juin 2016 16:59
À : nginx-devel at nginx.org
Objet : Re: [module dev] PCRE compiled code lost at reload


On Wed, Jun 22, 2016 at 02:49:36PM +0000, MAGNIEN, Thierry wrote:

> I think I start understanding what's wrong.
> Let me explain what I've done:
> I have a ngx_http_mymodule_data_t struct which include this:
> ngx_pool_t                    *regex_pool;
> After initializing my data struct in shared memory, I do something like this:
> my_data->regex_pool = ngx_create_pool(REGEX_POOL_SIZE, cycle->log);
> Later, at regex compilation, I use this:
> my_regex.pool = ((ngx_http_mymodule_data_t *)(sr_shm_zone->data))->regex_pool;

This is not going to work.  The "regex_pool" here is just a
pointer to a pool somewhere in process memory.  And each process
has it's own pool, if at all.  It likely seems to work (i.e.,
don't cause immediate segfault) because you create the pool in the
master process, hence all processes has copies of the pool.  But
it doesn't make the data allocated from such pools shared.

Maxim Dounin

nginx-devel mailing list
nginx-devel at nginx.org

More information about the nginx-devel mailing list