Re: PerlModule lifetime / threads

Perrin Harkins <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
On Wed, May 19, 2010 at 4:37 PM, Some Guy <[email protected]> wrote:
> if I have a ChildInitHandler, any changes I make to globals are not
> reflected in a HeaderParserHandler.  My globals do not have the :shared
> attribute - must they?

Only if you're trying to update them from a different thread.  If
there aren't multiple threads involved, you can update globals from
anywhere.  If that's not working for you there's probably a mistake in
the way you're referring to the variables.  If you post some code we
may be able to help.

> Is there a way to do what I want in mod_perl -
> namely have a HeaderParserHandler that uses data for some logic where that
> data is updated from some other thread that I spawn?

A more common approach with perl is to make a handler that runs in an
early phase which reloads the data as needed, and not use a separate
thread.  If you're concerned about reloading the data adding too much
delay to a web request, you could do this in a cleanup handler.

- Perrin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.