Bug 1863

Summary: NT_Service example performs invalid operations with -d
Product: ACE Reporter: Matthew Harris <mharris>
Component: ACE ExampleAssignee: DOC Center Support List (internal) <tao-support>
Status: ASSIGNED ---    
Severity: normal    
Priority: P3    
Version: 5.3   
Hardware: x86   
OS: Windows NT   

Description Matthew Harris 2004-06-24 17:25:06 CDT
The NT_Service example (essentially unchanged between ACE 5.3 and 5.4) has a -d
option that causes the example to run as an ordinary process rather than as a
service.  But even with this option the program makes service-related calls.  In
particular, Service::svc calls ACE_NT_Service::report_status, which calls
SetServiceStatus.  According to
<http://msdn.microsoft.com/library/en-us/dllproc/base/setservicestatus.asp>, "A
service can call [SetServiceStatus] only after it has called
RegisterServiceCtrlHandlerEx to get a service status handle," and with the -d
option the example does not do this.  (The program also calls
SetConsoleCtrlHandler to register a handler that calls Service::handle_control,
which also calls report_status.)

A comment in Service::svc indicates that the example assumes that report_status
returns -1 when the program is not being run as a service, but neither
SetServiceStatus nor report_status claims to properly handle this condition. 
Probably Process::run should handle opt_debug by starting the reactor without
using the Service instance at all.  Or ACE_NT_Service::report_status should not
call SetServiceStatus if this->svc_handle_ is null.
Comment 1 Steve Huston 2004-06-24 17:42:38 CDT
Accepted.