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
commit c55467dcd9eaf7782393633c8c9cd633780e1a33 Author: Gary Gregory <[email protected]> AuthorDate: Thu Nov 4 12:00:48 2021 -0400 reportServiceStatusE() shows a short description for dwCurrentState. --- src/changes/changes.xml | 6 ++++++ src/native/windows/apps/prunsrv/prunsrv.c | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 627a5ca..751e073 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -55,6 +55,12 @@ <action type="add" dev="ggregory" due-to="John Patrick"> Enable Dependabot #20. </action> + <action type="add" dev="ggregory" due-to="Gary Gregory"> + reportServiceStatusE() shows scale of dwWaitHint as millisecond in logging. + </action> + <action type="add" dev="ggregory" due-to="Gary Gregory"> + reportServiceStatusE() shows a short description for dwCurrentState. + </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/apps/prunsrv/prunsrv.c b/src/native/windows/apps/prunsrv/prunsrv.c index ee08eef..ac9ff8a 100644 --- a/src/native/windows/apps/prunsrv/prunsrv.c +++ b/src/native/windows/apps/prunsrv/prunsrv.c @@ -1031,6 +1031,17 @@ static BOOL docmdUpdateService(LPAPXCMDLINE lpCmdline) return rv; } +/** Maps dwCurrentState to the constant name described on https://docs.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_status */ +static const char* gSzCurrentState[] = { + "", + "SERVICE_STOPPED", + "SERVICE_START_PENDING", + "SERVICE_STOP_PENDING", + "SERVICE_RUNNING", + "SERVICE_CONTINUE_PENDING", + "SERVICE_PAUSE_PENDING", + "SERVICE_PAUSED" +}; /* Report the service status to the SCM, including service specific exit code. * @@ -1053,8 +1064,9 @@ static BOOL reportServiceStatusE(DWORD dwCurrentState, static DWORD dwCheckPoint = 1; BOOL fResult = TRUE; - apxLogWrite(APXLOG_MARK_DEBUG "reportServiceStatusE: dwCurrentState = %d, dwWin32ExitCode = %d, dwWaitHint = %d milliseconds, dwServiceSpecificExitCode = %d.", - dwCurrentState, dwWin32ExitCode, dwWaitHint, dwServiceSpecificExitCode); + int gSzCurrentStateIdx = dwCurrentState < 0 ? 0 : dwCurrentState > _countof(gSzCurrentState) ? 0 : dwCurrentState; + apxLogWrite(APXLOG_MARK_DEBUG "reportServiceStatusE: dwCurrentState = %d (%s), dwWin32ExitCode = %d, dwWaitHint = %d milliseconds, dwServiceSpecificExitCode = %d.", + dwCurrentState, gSzCurrentState[gSzCurrentStateIdx], dwWin32ExitCode, dwWaitHint, dwServiceSpecificExitCode); if (_service_mode && _service_status_handle) { if (dwCurrentState == SERVICE_RUNNING)
