On 2012-03-02 16:44, Rui Hu wrote:
hi,
My apache is running in worker MPM mode. And I wrote a module which uses
ap_get_module_conf and ap_set_module_conf to get& set core_module's data
once a request comes. So I am worried about following three potential
problems.
1. Does every request have a copy of core_module's configuration data?
No. They have pointers to configuration objects.
2. Is there any built-in synchronization mechanism existing in these two
functions?
No.
3. Should I add locking mechanism myself?
If I answer strictly to the question, I would say No. ap_set_module_conf
does something like array_of_pointers_to_conf_data_objects[module_index]
= address_of_conf_object.
So it is an assignment in an array. Normally this is done atomically.
If I digress, I would say that I am not sure your approach is safe.
First, configurations more often are read-only. Apache loads them at
startup and they do not change during the life-time of the server.
If you want to use request-specific data, you have other means, such as
r->request_config, r->notes, r->subprocess_env.
Second, it is good practice that modules create and use their own
configuration objects and do not change de configuration objects of
other modules.
Sorin