You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Graham Leggett <mi...@sharp.fm> on 1999/10/21 11:57:05 UTC

Apache loads config twice - why?

Hi all,

I am stuck with another conceptual problem.

While hunting a bug loading the 3rd party auth_ldap module, I discovered
Apache was loading it's configuration file twice. On the first config
attempt, all the LoadModule directives were successfully handled. On the
second config attempt, the attempt to dlopen the auth_ldap module
triggered an error and a dlopen bug which caused the program to
ungracefully exit right there.

I found this by adding a breakpoint to the load_module routine in
mod_so. Apache was executed with the -X option.

Is this correct behavior? Why would the config file be scanned twice? Is
this behavior to do with the -X flag?

The platform is Solaris v2.5.1.

Regards,
Graham
-- 
-----------------------------------------
minfrin@sharp.fm		"There's a moon
					over Bourbon Street
						tonight...

Re: Apache loads config twice - why?

Posted by Dean Gaudet <dg...@arctic.org>.
> Graham Leggett wrote:
> > 
> > It still doesn't explain why Apache would want to load everything twice.
> > Is it supposed to?
> > 

i think we should stop rationalizing this and just admit it's part of the
module writer hazing ritual ;)

Dean


Re: Apache loads config twice - why?

Posted by Jean-Luc Rochat <jn...@cybercable.fr>.
Graham Leggett wrote:
> 
> 
> It still doesn't explain why Apache would want to load everything twice.
> Is it supposed to?
> 
Wasn't it the "defensive programming" way of coding that is supposed to
check everything is OK before starting the real server process ?

Jean-Luc Rochat

Re: Apache loads config twice - why?

Posted by Pierpaolo Fumagalli <pi...@apache.org>.
Brian Behlendorf wrote:
> 
> On Thu, 21 Oct 1999, Graham Leggett wrote:
> >
> > It still doesn't explain why Apache would want to load everything twice.
> > Is it supposed to?
> 
> This should be added to the FAQ.  =)
> 
> Actually, I don't remember the exact reason, I think it's because Apache
> needs to find out where its other included config files are first before
> parsing them all, or something....
> 
> Then it was decided this was a good thing anyways, since if the server
> doesn't survive an instant reload, it won't survive being restarted
> anyways (for purposes of log rotation or whatever).
> 
Actually, a couple of years ago, a friend of mine to the same question
replied "Call it defensive programming" :) And after I had a little bit
of experience w/ Apache Modules programming, I had to agree
completely...

	Pier
-- 
Pierpaolo Fumagalli - IBM Center for Java Technologies
<ma...@us.ibm.com>   <ma...@apache.org>
======================================================
IBM Notes ID:  Pierpaolo Fumagalli/Cupertino/IBM@IBMUS
Telephone: +1 (408) 777-5838 - IBM Tieline #: 240-5838

Re: Apache loads config twice - why?

Posted by Ask Bjoern Hansen <as...@valueclick.com>.
On 22 Oct 1999 tvaughan@aventail.com wrote:

> > > Why not output these comments to stderr? Could perhaps ap_log_xxx output to 
> > > stderr just up until apache detaches itself from the terminal, and then the 
> > > log files are opened, and then ap_log_xxx outputs to the log files?
> > 
> > that is exactly what it does.  the first time through the config, the
> > errors go to stderr, the second time they go to the log.
> 
> Blush. I knew this. I guess I don't understand Ben's previous comment then.

People are relying on errors going to the error_log (configuration and
process control gets different when you have more than a handful of
servers), so Apache needs to do everything it can to try to make them end
there. Even if it's not going to start anyway.


 - ask

-- 
ask bjoern hansen - <http://www.netcetera.dk/~ask/>
more than 50M impressions per day, <http://valueclick.com>


Re: Apache loads config twice - why?

Posted by tv...@aventail.com.
Dean Gaudet <dg...@arctic.org> writes:

> On 22 Oct 1999 tvaughan@aventail.com wrote:
> 
> > Why not output these comments to stderr? Could perhaps ap_log_xxx output to 
> > stderr just up until apache detaches itself from the terminal, and then the 
> > log files are opened, and then ap_log_xxx outputs to the log files?
> 
> that is exactly what it does.  the first time through the config, the
> errors go to stderr, the second time they go to the log.

Blush. I knew this. I guess I don't understand Ben's previous comment then.

-Tom

-- 
Tom Vaughan <tvaughan at aventail dot com>

Re: Apache loads config twice - why?

Posted by Dean Gaudet <dg...@arctic.org>.
On 22 Oct 1999 tvaughan@aventail.com wrote:

> Why not output these comments to stderr? Could perhaps ap_log_xxx output to 
> stderr just up until apache detaches itself from the terminal, and then the 
> log files are opened, and then ap_log_xxx outputs to the log files?

that is exactly what it does.  the first time through the config, the
errors go to stderr, the second time they go to the log.

Dean


Re: Apache loads config twice - why?

Posted by tv...@aventail.com.
Ben Hyde <bh...@pobox.com> writes:

> Brian Behlendorf <br...@apache.org> writes:
> 
> > On Thu, 21 Oct 1999, Graham Leggett wrote:
> > > tvaughan@aventail.com wrote:
> ...
> > > It still doesn't explain why Apache would want to load everything twice.
> > > Is it supposed to?
> > 
> > This should be added to the FAQ.  =)
> > 
> > Actually, I don't remember the exact reason, I think it's because Apache
> > needs to find out where its other included config files are first before
> > parsing them all, or something.... 
> > 
> > Then it was decided this was a good thing anyways, since if the server
> > doesn't survive an instant reload, it won't survive being restarted
> > anyways (for purposes of log rotation or whatever).
> > 
> > 	Brian
> 
> One reason: it doesn't know where to write the log files (which can
> include comments on the configuration) until it has read the
> configuration.    - ben

Why not output these comments to stderr? Could perhaps ap_log_xxx output to 
stderr just up until apache detaches itself from the terminal, and then the 
log files are opened, and then ap_log_xxx outputs to the log files?

This would seem to make for a nice separation of "start-up" vs. "run-time"
messages.

-Tom

-- 
Tom Vaughan <tvaughan at aventail dot com>

Re: Apache loads config twice - why?

Posted by Ben Hyde <bh...@pobox.com>.
Brian Behlendorf <br...@apache.org> writes:

> On Thu, 21 Oct 1999, Graham Leggett wrote:
> > tvaughan@aventail.com wrote:
...
> > It still doesn't explain why Apache would want to load everything twice.
> > Is it supposed to?
> 
> This should be added to the FAQ.  =)
> 
> Actually, I don't remember the exact reason, I think it's because Apache
> needs to find out where its other included config files are first before
> parsing them all, or something.... 
> 
> Then it was decided this was a good thing anyways, since if the server
> doesn't survive an instant reload, it won't survive being restarted
> anyways (for purposes of log rotation or whatever).
> 
> 	Brian

One reason: it doesn't know where to write the log files (which can
include comments on the configuration) until it has read the
configuration.    - ben


Re: Apache loads config twice - why?

Posted by Brian Behlendorf <br...@apache.org>.
On Thu, 21 Oct 1999, Graham Leggett wrote:
> tvaughan@aventail.com wrote:
> 
> > I've been here before many o' time. Is the ldap library compiled with
> > "-fPIC"?
> 
> I don't know (closed source Netscape grumble grumble), but updating the
> patches on the OS seemed to fix the problem.
> 
> It still doesn't explain why Apache would want to load everything twice.
> Is it supposed to?

This should be added to the FAQ.  =)

Actually, I don't remember the exact reason, I think it's because Apache
needs to find out where its other included config files are first before
parsing them all, or something.... 

Then it was decided this was a good thing anyways, since if the server
doesn't survive an instant reload, it won't survive being restarted
anyways (for purposes of log rotation or whatever).

	Brian




Re: Apache loads config twice - why?

Posted by Graham Leggett <mi...@sharp.fm>.
tvaughan@aventail.com wrote:

> I've been here before many o' time. Is the ldap library compiled with
> "-fPIC"?

I don't know (closed source Netscape grumble grumble), but updating the
patches on the OS seemed to fix the problem.

It still doesn't explain why Apache would want to load everything twice.
Is it supposed to?

Regards,
Graham
-- 
-----------------------------------------
minfrin@sharp.fm		"There's a moon
					over Bourbon Street
						tonight...

Sv: Apache loads config twice - why?

Posted by Henrik Vendelbo <hv...@bluprints.com>.
According to the source this behaviour is for backwards compatibility.

----- Original Message ----- 
From: <tv...@aventail.com>
To: <ne...@apache.org>
Sent: Thursday, October 21, 1999 5:49 PM
Subject: Re: Apache loads config twice - why?


> Graham Leggett <mi...@sharp.fm> writes:
> 
> > Hi all,
> > 
> > I am stuck with another conceptual problem.
> > 
> > While hunting a bug loading the 3rd party auth_ldap module, I discovered
> > Apache was loading it's configuration file twice. On the first config
> > attempt, all the LoadModule directives were successfully handled. On the
> > second config attempt, the attempt to dlopen the auth_ldap module
> > triggered an error and a dlopen bug which caused the program to
> > ungracefully exit right there.
> > 
> > I found this by adding a breakpoint to the load_module routine in
> > mod_so. Apache was executed with the -X option.
> > 
> > Is this correct behavior? Why would the config file be scanned twice? Is
> > this behavior to do with the -X flag?
> > 
> > The platform is Solaris v2.5.1.
> 
> I've been here before many o' time. Is the ldap library compiled with
> "-fPIC"? 
> 
> -Tom
> 
> -- 
> Tom Vaughan <tvaughan at aventail dot com>
> 


Re: Apache loads config twice - why?

Posted by tv...@aventail.com.
Graham Leggett <mi...@sharp.fm> writes:

> Hi all,
> 
> I am stuck with another conceptual problem.
> 
> While hunting a bug loading the 3rd party auth_ldap module, I discovered
> Apache was loading it's configuration file twice. On the first config
> attempt, all the LoadModule directives were successfully handled. On the
> second config attempt, the attempt to dlopen the auth_ldap module
> triggered an error and a dlopen bug which caused the program to
> ungracefully exit right there.
> 
> I found this by adding a breakpoint to the load_module routine in
> mod_so. Apache was executed with the -X option.
> 
> Is this correct behavior? Why would the config file be scanned twice? Is
> this behavior to do with the -X flag?
> 
> The platform is Solaris v2.5.1.

I've been here before many o' time. Is the ldap library compiled with
"-fPIC"? 

-Tom

-- 
Tom Vaughan <tvaughan at aventail dot com>