You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/11/11 16:18:07 UTC
[commons-daemon] branch master updated: Add logging when failing to
set the options of a service.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-daemon.git
The following commit(s) were added to refs/heads/master by this push:
new 49c6a4a Add logging when failing to set the options of a service.
49c6a4a is described below
commit 49c6a4ac10b2760270468eac73043e1b0a94b7d7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Nov 11 11:18:05 2021 -0500
Add logging when failing to set the options of a service.
---
src/changes/changes.xml | 3 +++
src/native/windows/src/service.c | 30 +++++++++++++++++++-----------
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 8007c57..48b03a7 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -78,6 +78,9 @@
<action type="add" dev="ggregory" due-to="Gary Gregory">
Add logging when failing to obtain a service's description from the registry.
</action>
+ <action type="add" dev="ggregory" due-to="Gary Gregory">
+ Add logging when failing to set the options of a service.
+ </action>
<!-- -UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot">
Bump actions/cache from v2 to v2.1.6 #24, #30.
diff --git a/src/native/windows/src/service.c b/src/native/windows/src/service.c
index 9602825..56e6c5d 100644
--- a/src/native/windows/src/service.c
+++ b/src/native/windows/src/service.c
@@ -280,37 +280,45 @@ apxServiceSetNames(APXHANDLE hService,
BOOL
apxServiceSetOptions(APXHANDLE hService,
- DWORD dwServiceType,
- DWORD dwStartType,
- BOOL bDelayedStart,
- DWORD dwErrorControl)
+ DWORD dwServiceType,
+ DWORD dwStartType,
+ BOOL bDelayedStart,
+ DWORD dwErrorControl)
{
LPAPXSERVICE lpService;
SERVICE_DELAYED_AUTO_START_INFO sDelayedInfo;
- if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE) {
+ apxLogWrite(APXLOG_MARK_WARN "Can't set options for service.");
return FALSE;
+ }
lpService = APXHANDLE_DATA(hService);
/* Manager mode cannot handle services */
- if (lpService->bManagerMode)
+ if (lpService->bManagerMode) {
+ apxLogWrite(APXLOG_MARK_WARN "Can't set options for service: Manager mode cannot handle services");
return FALSE;
- /* Check if the ServixeOpen has been called */
- if (IS_INVALID_HANDLE(lpService->hService))
+ }
+ /* Check if the ServiceOpen has been called */
+ if (IS_INVALID_HANDLE(lpService->hService)) {
+ apxLogWrite(APXLOG_MARK_WARN "Can't set options for service: Service is not open.");
return FALSE;
+ }
if (!ChangeServiceConfig(lpService->hService, dwServiceType,
dwStartType, dwErrorControl,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL)) {
+ apxLogWrite(APXLOG_MARK_WARN "Can't set options for service: Failed to changes the configuration parameters.");
return FALSE;
}
if (dwStartType == SERVICE_AUTO_START) {
sDelayedInfo.fDelayedAutostart = bDelayedStart;
- return ChangeServiceConfig2A(lpService->hService,
- SERVICE_CONFIG_DELAYED_AUTO_START_INFO,
- &sDelayedInfo);
+ if (!ChangeServiceConfig2A(lpService->hService, SERVICE_CONFIG_DELAYED_AUTO_START_INFO, &sDelayedInfo)) {
+ apxLogWrite(APXLOG_MARK_WARN "Can't set options for service: Failed to changes the optional configuration parameters.");
+ return FALSE;
+ }
}
return TRUE;