httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sorin Manolache <sor...@gmail.com>
Subject Re: Windows service startup configuration - how to find out the "working" process?
Date Thu, 26 Apr 2012 10:33:57 GMT
On 2012-04-26 11:57, Waldemar Klein wrote:
> Thanks, that already helped a lot.
>
> I had this "post_config hook" thing somewhere in the back of my mind,
> but didn't connect it with my problem as a possible solution. While
> googling for it I also found child_init hook. I created logs to see
> when those are called, and it seems the child_init hook is ONLY called
> in the last, the "real working" configuration. I tested this with
> direct calling (-X), as service (-k start/stop/restart) and also when
> the service is started on boot, and it seems to work the same way
> always. So, I'll just transfer all the heavy work to the child_init
> hook.
>
> In the process I also found out that I can store data in the in a pool
> itself (i.e. not only allocating memory, but in a hash or table linked
> to the pool), which I wasn't aware is possible. This was my first plan
> to use to store a boolean variable, but the way child_init behaves, I
> won't need this, it might come in handy in the future. This is done
> with apr_pool_userdata_set and apr_pool_userdata_get.
>
> This is only for Apache on Windows, didn't try it on Linux. If I ever
> have to get it running on Linux, I'll cross that bridge when I come to
> it*
>

Again, I don't know how the permissions work in Windows. In Linux, the 
child_init hook is called by the non-privileged apache children. The 
post_config is called by the privileged parent.

Also, post_config is not called by the children. They get the modifs 
made in post_config through the inheritence that comes with process 
spawning because the parent runs post_config _before_ spawning its children.

If you put your heavy lifting in child_init, it will be executed every 
time the parent creates a child. So child creation will be slow. 
Children are often killed and recreated (they may have a finite upper 
bound on the number of requests they process), so child creation just 
happens even if your load is constant and no extra capacity would be needed.

I would put it in post_config. It is run a couple of times, apache 
restart/reloads could be slow, but at least you know that once it 
starts, it runs smoothly. At the end of the day, if you go for 
child_init, you'll run the conf parsing many more times.

Sorin

Mime
View raw message