httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sorin Manolache <>
Subject Re: Windows service startup configuration - how to find out the "working" process?
Date Wed, 25 Apr 2012 23:16:43 GMT
On 04/26/12 00:03, Waldemar Klein wrote:
> Hello.
> Looking at the startup procedure of Apache on Windows (as service), I
> noticed that the httpd.conf is read and processed (i.e. procedures
> ran) in total 4 times. After startup, only one of them is actually
> used later to handle requests.
> I have a module which has a rather expansive (reading and processing a
> few big files into memory) operation on startup. It is a waste of
> resources to do this 4 times, when it is used only once.
> What I found out so far:
> - the first process (pid A), runs as the user who entered the command
> httpd -k (re)start. Processes httpd.conf once. This will be terminated
> after startup is complete. It would not use and memory later on, but
> still it needs the processing time at startup.
> - the second (pid B) (runs as "SYSTEM") seems to be the "control"
> process and only starts another child process (pid B), processes
> httpd.conf once. Writes its pid to logs/ Stays as process but
> doesn't answer requests.
> - the third (pid C), processes the http.conf twice, only the second
> one is actually used.
> I can think of a few quite ugly hacks to solve this:
> - writing the pids to files and only doing the configuration work when
> I already see my own pid was in the file, this must be the 2nd run on
> the process with pid C (can also clean up then). Problemmatic with
> crashes during startup.
> - only prepare the config (store filenames) and finish (read and
> process files) the first time I actually get to work. Problem is,
> first request might take some time, because the "work" must be done.
> Could be solved by a dummy request right after startup. (it's still an
> ugly hack :) )
> - since I can identify the first process (different user), I could
> start a counter, and only read my files when the counter reaches 4.
> Problem: this doesnt work if apache is started with -X. (Also I
> haven't checked yet what the user of the 1st process is if it's
> started at boot or via a scheduled task)
> I can think of a few more problems that might arise, and I am even
> more afraid of the problems that I can not think of right now :)
> Now my question is, is there a good method to find out if we (the
> configuration procedures) are in the "working" configuration? This
> would be the third process and the 2nd processing of the httpd.conf,
> which will be actually used when the module gets to work.

Try not to do the heavy lifting during the configuration parsing. Put 
the heavy stuff in the post_config hook. You can combine it with a 
boolean variable whose state you switch after you did the heavy lifting 
once. I think it doesn't matter when you parse the conf. If you do it 
early, the child processes inherit the address space of the parent in 
which you already did you processing. The differences between the 
various parsings are the process permissions and availability of the log 

Please note that I didn't work with apache on Windows, so my advice is 
based on not-so-educated extrapolations.


View raw message