You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Michael B Allen <mb...@ioplex.com> on 2007/04/20 10:10:33 UTC

PHP Extension Deinitializing on Startup

I'm trying to track down a strange problem. I have a PHP extension
that is being deinitialized immediately after it starts up. After much
research I'm starting to think that only Apache would ultimately trigger
such an event.

Is there any reason why Apache would unload the PHP module immediately
after startup? Is there any way to enable some kind of debugging to see
Apache loading and unloading modules so that I might determine why PHP
is being unloaded?

Thanks,
Mike

Re: PHP Extension Deinitializing on Startup

Posted by Michael B Allen <mb...@ioplex.com>.
On Fri, 20 Apr 2007 11:08:15 -0600
Joe Lewis <jo...@joe-lewis.com> wrote:

> Michael B Allen wrote:
> > Hi Saju,
> >
> > Actually I'm not sure this is my problem. I have tested my PHP extension
> > on numerous platforms and I have only ever seen the PHP extension
> > initialization / deinitialization routines run once for each restart.
> >
> > Is the "load -> unload -> load" behavior you describe something new that
> > Apache just started doing?
> >   
> 
> Apache has been doing that for eons. But apache does it to the apache 
> extensions, while PHP would do it to the PHP extensions. I really expect 
> that you should be working with the PHP lists rather than here from the 
> original posting. (See http://www.php.net/mailing-lists.php for one that 
> might fit your needs).
> 
> Saju is absolutely correct - when a module is loaded by apache, a hook 
> called post_config() is called twice (for checking the config file first 
> that the syntax is okay, and then for the actual configuration), but I'm 
> not sure if the .so is free()d from memory during that process. I always 
> thought that it did not actually reload the .so (correct me if I am wrong).
> 
> Forcing an extension to "deinitialize" in PHP because of an issue in 
> Apache would cause every extension in PHP to "deinitialize", not just 
> one of them. I expect the issue to be in the php extension itself (or 
> php, but that is unlikely).

Ok, thanks Joe.

I have been asking about this on the PHP list. I'm trying to work
all angles.

Mike

Re: PHP Extension Deinitializing on Startup

Posted by Saju Pillai <sa...@gmail.com>.
On 20/04/07, Joe Lewis <jo...@joe-lewis.com> wrote:
> Michael B Allen wrote:
> > Hi Saju,
> >
> > Actually I'm not sure this is my problem. I have tested my PHP extension
> > on numerous platforms and I have only ever seen the PHP extension
> > initialization / deinitialization routines run once for each restart.
> >
> > Is the "load -> unload -> load" behavior you describe something new that
> > Apache just started doing?
> >
>
> Apache has been doing that for eons. But apache does it to the apache
> extensions, while PHP would do it to the PHP extensions. I really expect
> that you should be working with the PHP lists rather than here from the
> original posting. (See http://www.php.net/mailing-lists.php for one that
> might fit your needs).
>
> Saju is absolutely correct - when a module is loaded by apache, a hook
> called post_config() is called twice (for checking the config file first
> that the syntax is okay, and then for the actual configuration), but I'm
> not sure if the .so is free()d from memory during that process. I always
> thought that it did not actually reload the .so (correct me if I am wrong).
>

mod_so loads a module using apr_dso_load() . This call registers a
pool cleanup callback that is called during config pool clearing to
unload the dso.

Without all modules getting unloaded in a restart cycle, you would not
be able to get rid of a module across restarts by commenting out it's
LoadModule.

-srp

> Forcing an extension to "deinitialize" in PHP because of an issue in
> Apache would cause every extension in PHP to "deinitialize", not just
> one of them. I expect the issue to be in the php extension itself (or
> php, but that is unlikely).
>
> Joe
> --
> Joseph Lewis <http://sharktooth.org/>
> "Divide the fire, and you will sooner put it out." - Publius Syrus
>

Re: PHP Extension Deinitializing on Startup

Posted by Joe Lewis <jo...@joe-lewis.com>.
Michael B Allen wrote:
> Hi Saju,
>
> Actually I'm not sure this is my problem. I have tested my PHP extension
> on numerous platforms and I have only ever seen the PHP extension
> initialization / deinitialization routines run once for each restart.
>
> Is the "load -> unload -> load" behavior you describe something new that
> Apache just started doing?
>   

Apache has been doing that for eons. But apache does it to the apache 
extensions, while PHP would do it to the PHP extensions. I really expect 
that you should be working with the PHP lists rather than here from the 
original posting. (See http://www.php.net/mailing-lists.php for one that 
might fit your needs).

Saju is absolutely correct - when a module is loaded by apache, a hook 
called post_config() is called twice (for checking the config file first 
that the syntax is okay, and then for the actual configuration), but I'm 
not sure if the .so is free()d from memory during that process. I always 
thought that it did not actually reload the .so (correct me if I am wrong).

Forcing an extension to "deinitialize" in PHP because of an issue in 
Apache would cause every extension in PHP to "deinitialize", not just 
one of them. I expect the issue to be in the php extension itself (or 
php, but that is unlikely).

Joe
-- 
Joseph Lewis <http://sharktooth.org/>
"Divide the fire, and you will sooner put it out." - Publius Syrus

Re: PHP Extension Deinitializing on Startup

Posted by Michael B Allen <mb...@ioplex.com>.
Hi Saju,

Actually I'm not sure this is my problem. I have tested my PHP extension
on numerous platforms and I have only ever seen the PHP extension
initialization / deinitialization routines run once for each restart.

Is the "load -> unload -> load" behavior you describe something new that
Apache just started doing?

If not, I think I might have a different problem.

Mike

On Fri, 20 Apr 2007 17:57:22 +0530
"Saju Pillai" <sa...@gmail.com> wrote:

> The apache config cycle will load -> unload -> load your module on
> startup. Infact your module gets reloaded in for every restart
> 
> -srp
> 
> On 20/04/07, Michael B Allen <mb...@ioplex.com> wrote:
> > I'm trying to track down a strange problem. I have a PHP extension
> > that is being deinitialized immediately after it starts up. After much
> > research I'm starting to think that only Apache would ultimately trigger
> > such an event.
> >
> > Is there any reason why Apache would unload the PHP module immediately
> > after startup? Is there any way to enable some kind of debugging to see
> > Apache loading and unloading modules so that I might determine why PHP
> > is being unloaded?
> >
> > Thanks,
> > Mike
> >
> 

Re: PHP Extension Deinitializing on Startup

Posted by Saju Pillai <sa...@gmail.com>.
The apache config cycle will load -> unload -> load your module on
startup. Infact your module gets reloaded in for every restart

-srp

On 20/04/07, Michael B Allen <mb...@ioplex.com> wrote:
> I'm trying to track down a strange problem. I have a PHP extension
> that is being deinitialized immediately after it starts up. After much
> research I'm starting to think that only Apache would ultimately trigger
> such an event.
>
> Is there any reason why Apache would unload the PHP module immediately
> after startup? Is there any way to enable some kind of debugging to see
> Apache loading and unloading modules so that I might determine why PHP
> is being unloaded?
>
> Thanks,
> Mike
>

Re: [SOLVED] PHP Extension Deinitializing on Startup

Posted by Michael B Allen <mb...@ioplex.com>.
One word: SELinux

> I'm trying to track down a strange problem. I have a PHP extension
> that is being deinitialized immediately after it starts up.