httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MegaBrutal <megabru...@gmail.com>
Subject [users@httpd] Windows: Apache 2.2 service ignores shutdown
Date Tue, 17 Aug 2010 17:57:51 GMT
Hello,

I noticed that after I restart my system, there are signs that Apache
was shut down uncleanly (httpd.pid stays there, error.log doesn't
contain data on exiting). I also see a warning in my error.log, like:
[Tue Aug 17 18:43:06 2010] [warn] pid file C:/Program Files/Apache
Software Foundation/Apache2.2/logs/httpd.pid overwritten -- Unclean
shutdown of previous Apache run?

Note that I always shut down my computer cleanly. On a clean shutdown,
services should exit cleanly as well, but Apache doesn't.

Indeed, when I issue an "sc query Apache2.2" command, I see the following:

SERVICE_NAME: Apache2.2
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

It says, the Apache service ignores shutdown - it lets itself
terminated by Windows uncleanly. I've downloaded the source code, and
I've found the problem in /server/mpm/winnt/service.c, in function
"ReportStatusToSCMgr" and "service_nt_ctrl".

I wouldn't like to mess around and making a patch, so I supply what
would need to be changed here:

This line in "ReportStatusToSCMgr":
globdat.ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
Should be replaced with this:
globdat.ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP |
SERVICE_ACCEPT_PRESHUTDOWN | SERVICE_ACCEPT_SHUTDOWN;

This line in "service_nt_ctrl":
if (dwCtrlCode == SERVICE_CONTROL_STOP)
Should be replaced with:
if ((dwCtrlCode == SERVICE_CONTROL_STOP) || (dwCtrlCode ==
SERVICE_CONTROL_PRESHUTDOWN) || (dwCtrlCode ==
SERVICE_CONTROL_SHUTDOWN))

NOTE: SERVICE_ACCEPT_PRESHUTDOWN and SERVICE_CONTROL_PRESHUTDOWN are
only supported in Windows Vista and above, however AFAIK earlier
Windows versions just ignore it. So it wouldn't cause compatibility
problems. On Vista & 7, the service would be shut down by a
PRESHUTDOWN; on XP and earlier, it would be shut down by a SHUTDOWN.
If you wouldn't like to use PRESHUTDOWN, it's OK, I just suggest it,
because I noticed that it takes several seconds for Apache to shut
down, so where possible, I'd start it earlier (that's the purpose of
PRESHUTDOWN) to make sure that Apache won't run out of time.

If you'd really like me to make a patch, then I will, but first I
posted it here - it's just a minor modification, maybe it would be
easier to add for someone who already set up their system to compile
Apache on Windows, and doesn't always forget the proper "diff" command
that makes proper patches. ;) But still, if you don't feel like to do
it, I'll make a patch and also test the feature, if you promise you'd
include it in the next release.


Best regards,
MegaBrutal


P.S.: Ooops! Sorry, I was a bit outdated. I've just downloaded the
2.3.6-alpha source code, and I notice you've already added support for
SERVICE_CONTROL_SHUTDOWN. I don't feel like to recompose my e-mail
after all. You could still consider adding SERVICE_CONTROL_PRESHUTDOWN
then.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message