# Unexpected Extension Deinitializing on Startup

- Thread: https://externals.io/message/28928
- Original archive: https://news-web.php.net/php.internals/28928
- Started by Michael B Allen on 2007-04-20T03:46:08+00:00
- Messages: 7
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #28928 — Michael B Allen — 2007-04-20T03:46:08+00:00

URL: https://externals.io/message/28928#28928

Is there an Apache or PHP setting that would cause an extension to be
deinitilized in the initial root process on startup?

We have an extension that forks a process from the initial Apache root
process and does privileged work. The regular Apache workers running as
'apache' communicate with this root process using a pipe and shared
memory. We need that root process running.

Anyway, I have a customer who is seeing the extension initialize,
everything starts up great, and then the extension deinitialization
routine is called. For any other extension this behavior probably goes
unnoticed because (I suspect) the Apache worker processes do not see the
deinitializtion. Only the root process (not sure about that).  But for
our extension, we need the root process working so the deinitialization
kills our extension.

Is there some kind of Apache process model setting or something like
that or a bug that could cause the deinitialization routine to run?

Env is CentOS 4.4 with stock packages (PHP 5.1.6).

Any help with this would be greatly appreciated.

Mike

-- 
Michael B Allen
PHP Active Directory Kerberos SSO
http://www.ioplex.com/

---

## #28929 — Derick Rethans — 2007-04-20T07:20:26+00:00

URL: https://externals.io/message/28928#28929 · In reply to: #28928

> Is there an Apache or PHP setting that would cause an extension to be
> deinitilized in the initial root process on startup?

It's an Apache thing. First it brings up all modules (like mod_php) to 
figure out which settings it supports. Then it shuts down everything. 
Then it starts the real start up process and initializes all modules 
again.

regards,
Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #28930 — Michael B Allen — 2007-04-20T07:51:54+00:00

URL: https://externals.io/message/28928#28930 · In reply to: #28929

On Fri, 20 Apr 2007 09:20:26 +0200 (CEST)
Derick Rethans <derick@php.net> wrote:

> 
> 
> > […]
> 
> It's an Apache thing. First it brings up all modules (like mod_php) to 
> figure out which settings it supports. Then it shuts down everything. 
> Then it starts the real start up process and initializes all modules 
> again.

Hi Derick,

Is this behavior documented anywhere? I suppose I should just get on
the Apache list and ask there ...

Mike

-- 
Michael B Allen
PHP Active Directory Kerberos SSO
http://www.ioplex.com/

---

## #28931 — Derick Rethans — 2007-04-20T07:54:16+00:00

URL: https://externals.io/message/28928#28931 · In reply to: #28930

> On Fri, 20 Apr 2007 09:20:26 +0200 (CEST)
> Derick Rethans <derick@php.net> wrote:
> 
> > […]
> 
> Is this behavior documented anywhere? I suppose I should just get on 
> the Apache list and ask there ...

Hmm, I don't know where this is documented. The Apache list might indeed 
be the best medium to ask.

regards,
Derick

---

## #28932 — Rasmus Lerdorf — 2007-04-20T08:57:45+00:00

URL: https://externals.io/message/28928#28932 · In reply to: #28930

Michael B Allen wrote:
> On Fri, 20 Apr 2007 09:20:26 +0200 (CEST)
> Derick Rethans <derick@php.net> wrote:
> 
> > […]
> 
> Hi Derick,
> 
> Is this behavior documented anywhere? I suppose I should just get on
> the Apache list and ask there ...

This question has probably been asked a hundred times on the Apache
lists.  There really isn't much decent documentation out there on how to
write Apache modules.  The Apache1 code is rather simple, so most people
just read the server code to figure it out.  The closest thing to real
documentation is an old book called "Writing Apache Modules with Perl
and C" by Lincoln Stein and Doug MacEachern.  You'll want to read
chapter 3 - "The Apache Module Architecture and API" where this
particular topic is covered.

-Rasmus

---

## #28938 — Michael B Allen — 2007-04-20T15:23:22+00:00

URL: https://externals.io/message/28928#28938 · In reply to: #28932

On Fri, 20 Apr 2007 01:57:45 -0700
Rasmus Lerdorf <rasmus@lerdorf.com> wrote:

> Michael B Allen wrote:
> > […]
> 
> This question has probably been asked a hundred times on the Apache
> lists.  There really isn't much decent documentation out there on how to
> write Apache modules.  The Apache1 code is rather simple, so most people
> just read the server code to figure it out.  The closest thing to real
> documentation is an old book called "Writing Apache Modules with Perl
> and C" by Lincoln Stein and Doug MacEachern.  You'll want to read
> chapter 3 - "The Apache Module Architecture and API" where this
> particular topic is covered.

Well it doesn't sound like this is something they just started doing. My
PHP extension has been tested on numerous platforms and I have only ever
seen the PHP module initialization / deinitialization routines called
once on startup / shutdown. Even if the actual PHP module is loaded
and unloaded, do you call the (de)initialization routines for each
(unl)load? I'm not sure this issue is the issue I'm seeing.

Mike

-- 
Michael B Allen
PHP Active Directory Kerberos SSO
http://www.ioplex.com/

---

## #28942 — Michael B Allen — 2007-04-21T02:54:30+00:00

URL: https://externals.io/message/28928#28942 · In reply to: #28928

One word: SELinux

On Thu, 19 Apr 2007 23:46:08 -0400
Michael B Allen <mba2000@ioplex.com> wrote:

> We have an extension that forks a process from the initial Apache root
> process and does privileged work. The regular Apache workers running as
> 'apache' communicate with this root process using a pipe and shared
> memory. We need that root process running.
> 
> Anyway, I have a customer who is seeing the extension initialize,
> everything starts up great, and then the extension deinitialization
> routine is called.

-- 
Michael B Allen
PHP Active Directory Kerberos SSO
http://www.ioplex.com/
