httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sorin Manolache <>
Subject Re: Question about global data
Date Mon, 09 Feb 2009 18:26:36 GMT
On Mon, Feb 9, 2009 at 19:04, Thomas Moyer <> wrote:
> Hash: SHA1
> Is it possible to have some global data that is accessible to all request
> threads.  Something like a socket is what I am interested in. For example,
> if I have a socket that opens a connection to another system, I would like
> to share this one open socket across all threads.  If this isn't possible,
> what are other options for sharing something like a socket between multiple
> request threads.

You simply declare a global variable in the source file.

You open the connection either in post_config or in child_init hook.
post_config is called when apache starts and each time the
configuration is reloaded, and it is called before apache forks its
children. post_config is called with the effective UID of the user who
starts apache (typically root), while child_init is called with the
effective UID defined in the User configuration directive (a
non-privileged user, typically www-data or nobody). child_init is run
once in each apache child upon child creation.

So, in the first case, you would have one file descriptor shared by
all processes, while in the second case you would have N open
connections to your backend, where N is the number of apache

In any case, all threads in a process share the socket.


A: Because it reverses the logical flow of conversation.
Q: Why is top-posting frowned upon?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

View raw message