[module dev] PCRE compiled code lost at reload
Maxim Dounin
mdounin at mdounin.ru
Wed Jun 22 14:59:21 UTC 2016
Hello!
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
http://nginx.org/
More information about the nginx-devel
mailing list