On 23/05/07, César Leonardo Blum Silveira <[EMAIL PROTECTED]> wrote:
Hello all,

I have some questions about handling data within modules. I will try
to be as clear as possible.

1) Each module is loaded once per server, right?

Yes, although there is a bit more to it than that when you consider restarts.

In which processes address space is it loaded?

The initial Apache parent process. It is then inherited by the Apache
child processes when they are forked off from the parent.

2) Suppose I have a global variable in a module. Using the prefork
MPM, will all processes see the updated value all the time, or will
each process have a separate value for the global variable?

Each Apache child process will have their own copy and writing to it
will only affect that processes copy. Ie., other processes will not
see an update.

3) If I want to have an apr_table_t in my module config structure, is
there any way to share it between the Apache processes (again, suppose
that I'm using the prefork MPM)?

Not an actual apr_table_t instance as such.

To share data between processes you would need to use shared memory or
something equivalent. Placing more complicated data structures in
shared memory can though be more tricky though than simple data
variables.

Apache itself uses what it calls the scoreboard for communicating
information between processes, in effect a wrapper around a shared
memory mechanism.

FWIW, you might want to read through:

 http://www.fmc-modeling.org/projects/apache/html/Apache_Modeling_Project.html

It explains more about how modules are loaded into Apache, how child
processes are created and managed, how Apache uses the scoreboard
mechanism etc. It is quite technical and in depth though so may be
more than what you want to know.

Graham

Reply via email to