[Win32utils-devel] Stopping services
Daniel.Berger at qwest.com
Fri Sep 9 11:45:12 EDT 2005
> -----Original Message-----
> From: win32utils-devel-bounces at rubyforge.org
> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of
> Nathaniel Talbott
> Sent: Friday, September 09, 2005 6:20 AM
> To: Development and ideas for win32utils projects
> Subject: Re: [Win32utils-devel] Stopping services
> Really? Even with your wiz-bang mad C hackery skillz? :-)
My mad C hackery skillz led me to this in the Service_Ctrl function:
// Tell service_main thread to stop.
if ((dwCtrlCode == SERVICE_CONTROL_STOP) ||
(dwCtrlCode == SERVICE_CONTROL_SHUTDOWN))
// Raise an error here?
So, if SetEvent (a Windows function) fails, we call ErrorStopService
(our function). Looking at ErrorStopService I see this:
// If you have threads running, tell them to stop. Something went
// wrong, and you need to stop them so you can inform the SCM.
// Stop the service.
SetTheServiceStatus(SERVICE_STOPPED, GetLastError(), 0, 0);
Looking at SetTheServiceStatus (our function) I see this:
// Send status of the service to the Service Controller.
It almost looks like we could end up with an infinite loop. Is the SCM
saving our butt here by just timing out and shutting down the service
for us? I'm not sure.
I think we need to look more closely at why SetEvent() is failing.
Perhaps raising an error is in order. That's where I'm going to start
More information about the win32utils-devel