httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Costello <>
Subject RE: Platform Specific MPM Design Questions
Date Thu, 01 Jan 1970 00:00:00 GMT
On Tuesday, 23 May 2000, William A. Rowe, Jr. wrote:
> 1) If this is the Win32 mpm, we need two arguments, -k and -n, which
>    could be extracted from the argv/argc list, with the clean list
>    retained for command argument parsing.  No special mpm arg_hook
>    is required for alien arguments.

So you want to put the command-line processing that deals with service control
into the MPM, and you need the process_rec to get at the command line. Is this
right so far? Is ap_server_argv0 an alternative?

Also, dumb question #1 for today: what's an alien argument?

> 2) If this is a WinNT service, something very odd needs to happen.
>    On pass one, the Service Control Manager is invoked with Apache's
>    main() function all over again.  The original main() code path
>    never finishes, this is the end of it's life.  This will now be
>    invoked by an internal -k runservice flag, rather than console 
>    session tests.
>    On the second pass, we replace argv[0] with the true argv[0]
>    (since it is passed the service name by the SCM, rather than the
>    executable name), and we insert -f and -d args from the Win32 
>    service control registry.  (These CAN be overriden, however,
>    when starting the service.)

So how do you tell if you're running as a service in the first place (ie. to
set the -k runservice flag)? 

What do you mean by "all over again" above? What came before (this is pass
one)? At the moment startup looks like:
    * apache service started / exe invoked by SCM
    * test to see if service - if so, do service stuff (SetServiceStatus) as
      well as everything else

Can you outline what it will look like after the proposed changes?

> Everything else I am looking to move into the MPM can happen in the
> ap_run_pre_config or ap_post_config_hook phase (depending). 
> ap_run_pre_config phase will handle:
>    -n servicename -k stop       {we don't care if the config is valid}
>    -n servicename -k uninstall  {we really don't care if the config is valid :-}
> ap_post_config_hook phase will handle:
>    -n servicename -k runservice {internal Win9x only: show the fools their errors}
>    -n servicename -k restart    {no sense in restarting if the config has errors}
>    -n servicename -k start      {error out if trying to launch with new errors on WinNT}
>    -n servicename -k install    {be sure the config is valid, at least at the moment
>    and process termination hooks for ^C/Close Window/Stop Service/Shutdown etc...

All right, I'm really confused now. You said above that -k runservice would
apply if it was a WinNT service, but just then "internal Win9x only". 

When you say "error out ... WinNT", a config error will presumably cause the
process to end. If this happens before we do SetServiceStatus(
SERVICE_START_PENDING) then the SCM will hang, waiting for a response. 

What if someone tries to start the service using net start, or the services
applet in the control panel? Is this the NT -k runservice? Re: previous
question about detecting when apache is a service. 

> I've spent many hours staring at these code paths... I agree it's a hack, but
> I need the environment prior to the command line parsing, before much is 
> initialized (since the NT service will loop).  But I think all would like to
> see every platform run with the same process sequence.  I'm open to any
> alternative suggestions.

When I understand what the changes are, and how it might work, I'll be more
than happy to try suggesting something. 

And Greg Stein said:
> > I'm also looking at a way to hook in the NT service processing
> > without the recursive call to main() (but with expanded argv[]).
> > It will certainly involve a little bit of setjmp or stack
> > manipulation, but I should be able to accomplish it.
> Okay. That just sounds nasty. It seems that there *has* to be a better way
> to solve the problem than to use setjmp.

I agree. I look forward to understanding the recursive main() bit. :-)


This message was sent through MyMail

View raw message