Re: PerlModule lifetime / threads

Some Guy <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
The cleanup handler is a brilliant idea.  That removes the need for a
polling thread.  If I attach the cleanup to the request's pool and run in a
threaded MPM, this led to contention for the globals that I'm updating in
C.  Is this the case with PerlModules, or can I get away without locking
them?

Thanks,

SB

On Wed, May 19, 2010 at 6:13 PM, Perrin Harkins <[email protected]> wrote:

> 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.