Alberto Canzi <[EMAIL PROTECTED]> said something to this effect on 07/05/2001:
> Hi, I'm writing a perl module for Apache, but I have this
> problem: 
>
> I need to allocate some memory that will persist for the entire
> apache server's cycle of life. (That is: I need to allocate
> some memory at the server's start that could be read and
> written by my module. In other words : my module (that is
> called by server when it receives a request) should be able to
> read and write some data to that memory area and at subsequent
> request made to the server my module must have access to that
> data ... 
>
> (Now the only solution I've found is to write that data to a
> file ... but it isn't a good thing because of synchronizations
> problems...) 

Please, no HTML mail!

With Apache, allocating a buffer that is shared across the
"entire server" is difficult, since Apache forks, and the
children handle incoming connections. Sharing data across a child
is not difficult, with mod_perl. To make data available across
all the requests that one child handles, consider using a global
variable (they persist from request to request in the same child,
under mod_perl; see
http://thingy.kcilink.com/modperlguide/porting/Global_Variables_Persistence.html).
To make data available to different phases of the same request,
use pnotes (see
http://thingy.kcilink.com/modperlguide/snippets/Passing_and_Preserving_Custom_Da.html
and
http://thingy.kcilink.com/modperlguide/snippets/Passing_Notes_Between_mod_perl_a.html)

If you are talking about being able to maintain a single data
drop that all the server processes can access, consider a
database wrapped in a library.  Also consider Apache::Session,
which is suitable for sharing data across children in a
useful (and easily syncronized) way.

(darren)

-- 
"One Architecture, One OS" also translates as "One Egg, One Basket".

Reply via email to