On Wed, Apr 25, 2001 at 10:59:51PM +0800, Stas Beckman wrote:
> On Wed, 25 Apr 2001, Philippe M . Chiasson wrote:
>
> > A suggested new feature.
> >
> > Apache->dso_module('mod_example.c') behaves like
> > Apache->module('mod_example.c') except it returns 1 if the
> > module is loaded as DSO, 0 if it's compiled in and undef
> > if it's not present at all.
> >
> > I wrote this because of a few problems I had with the 'slight'
> > differences in behaviour of mod_perl under DSO and compiled in.
> >
> > In my case, I call an init function from a startup.pl, and because
> > of the way apache starts then restarts, it gets called twice if mod_perl
> > is compiled in and only once if it's a DSO.
> >
> > So I end up with code like this:
> >
> > sub init {
> >     return if($Apache::Server::Starting && not $Global::MOD_PERL_AS_DSO);
> >     }
> >
>
> Back to the old problem... Eric Cholet has implemented
> $Apache::Server::Restarting, but for various reasons it's never went in.
>
> Currently I think there is a slight "bug" in the latest mod_perl 1.x,
> where PerlRequire doesn't work as require() in Perl per se on restart. A
> few people have reported this behavior.
>
> So as a quick workaround do this:
>
> start.pl:
> ---------
> require "real-startup.pl";
>
> this require(), won't be called twice.

I know that, but my problem is that I need to call an init() function
in a loaded library that can't be called twice ;-(

>
> > I guess it could be usefull for other purposes to, so here is the patch.
>
> I'm not underestimating the power of your patch of course :) I think the
> real fix should be in PerlRequire.

Yeah, Matt said he could use it ;-)

>
> BTW, the same problem happens to PerlModule. I've moved all my preloadings
> into the Perl domain, mod_perl reloads them twice.

I agree, I experienced the strange differences between PerlModule Foo &
<Perl>use Foo;</Perl> ;-(

I guess that problem couold be fixed usign perl_module->dynamic_load_handle.
That way code like PerlModule and such could figure out if they should
skip the first run or not.

I wouldn't mind volunteering to look at this problem and suggest a fix. It's
been annoying for a long time now.

There is also the strange case of mod_perl leaking memory on graceful resta=
rts
when compiled as DSO.  But I don't feel like getting into this one quite ye=
t.

> _____________________________________________________________________
> Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
> http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
> mailto:[EMAIL PROTECTED]   http://apachetoday.com http://logilune.com/
> http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
>
>
>

--
+-----------------------------------------------+
| Philippe M. Chiasson  <[EMAIL PROTECTED]>        |
| SmartWorker http://www.smartworker.org        |
|     IM : gozerhbe  ICQ : gozer/18279998       |
|   64.8% computer corrupt according to         |
| http://www.freespeech.org/ljk/purity.html     |
+-----------------------------------------------+
die_if_kernel("Whee... Hello Mr. Penguin",current->tss.kregs);
        -- Linux        2.2.16
        /usr/src/linux/arch/sparc/kernel/traps.c

perl -e '$$=3D\${gozer};{$_=3Dunpack(P26,pack(L,$$));/^Just Another Perl 
Hacker!\n$/&&print||$$++&&redo}'

Reply via email to