Bug 1863 - NT_Service example performs invalid operations with -d
Summary: NT_Service example performs invalid operations with -d
Status: ASSIGNED
Alias: None
Product: ACE
Classification: Unclassified
Component: ACE Example (show other bugs)
Version: 5.3
Hardware: x86 Windows NT
: P3 normal
Assignee: DOC Center Support List (internal)
URL:
Depends on:
Blocks:
 
Reported: 2004-06-24 17:25 CDT by Matthew Harris
Modified: 2004-06-24 17:42 CDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.