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 a7c5367f1e290978c408ace88a3169b9d3d00e50 Author: Gary Gregory <[email protected]> AuthorDate: Wed Nov 10 08:40:57 2021 -0500 Refactor getting a name for a service status state into a function. Better API name. --- src/native/windows/apps/prunsrv/prunsrv.c | 2 +- src/native/windows/src/private.h | 2 +- src/native/windows/src/service.c | 36 +++++++++++++++---------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/native/windows/apps/prunsrv/prunsrv.c b/src/native/windows/apps/prunsrv/prunsrv.c index 59077d1..1eb189f 100644 --- a/src/native/windows/apps/prunsrv/prunsrv.c +++ b/src/native/windows/apps/prunsrv/prunsrv.c @@ -1055,7 +1055,7 @@ static BOOL reportServiceStatusE(DWORD dwLevel, apxLogWrite(NULL, dwLevel, TRUE, __FILE__, __LINE__, "reportServiceStatusE: dwCurrentState = %d (%s), dwWin32ExitCode = %d, dwWaitHint = %d milliseconds, dwServiceSpecificExitCode = %d.", - dwCurrentState, apxServiceGetCurrentStateName(dwCurrentState), dwWin32ExitCode, dwWaitHint, dwServiceSpecificExitCode); + dwCurrentState, apxServiceGetStateName(dwCurrentState), dwWin32ExitCode, dwWaitHint, dwServiceSpecificExitCode); if (_service_mode && _service_status_handle) { if (dwCurrentState == SERVICE_RUNNING) diff --git a/src/native/windows/src/private.h b/src/native/windows/src/private.h index 55d8072..6f64dd6 100644 --- a/src/native/windows/src/private.h +++ b/src/native/windows/src/private.h @@ -240,7 +240,7 @@ BOOL apxGetServiceDescriptionW(LPCWSTR szServiceName, LPWSTR szDescription, DWORD dwDescriptionLength); BOOL apxGetServiceUserW(LPCWSTR szServiceName, LPWSTR szUser, DWORD dwUserLength); -const char* apxServiceGetCurrentStateName(DWORD dwCurrentState); +const char* apxServiceGetStateName(DWORD dwCurrentState); DWORD __apxGetMultiSzLengthA(LPCSTR lpStr, LPDWORD lpdwCount); DWORD __apxGetMultiSzLengthW(LPCWSTR lpStr, LPDWORD lpdwCount); diff --git a/src/native/windows/src/service.c b/src/native/windows/src/service.c index d59118b..e7bde88 100644 --- a/src/native/windows/src/service.c +++ b/src/native/windows/src/service.c @@ -46,7 +46,7 @@ static const char* gSzCurrentState[] = { "SERVICE_PAUSED" }; -const char* apxServiceGetCurrentStateName(DWORD dwCurrentState) { +const char* apxServiceGetStateName(DWORD dwCurrentState) { return gSzCurrentState[dwCurrentState < 0 ? 0 : dwCurrentState > _countof(gSzCurrentState) ? 0 : dwCurrentState]; } @@ -423,7 +423,7 @@ apxServiceControl(APXHANDLE hService, DWORD dwControl, UINT uMsg, { LPAPXSERVICE lpService; SERVICE_STATUS stStatus; - DWORD dwPending = 0; + DWORD dwPendingState = 0; DWORD dwState = 0; DWORD dwTick = 0; DWORD dwWait, dwCheck, dwStart, sleepMillis; @@ -445,16 +445,16 @@ apxServiceControl(APXHANDLE hService, DWORD dwControl, UINT uMsg, } switch (dwControl) { case SERVICE_CONTROL_CONTINUE: - dwPending = SERVICE_START_PENDING; - dwState = SERVICE_RUNNING; + dwPendingState = SERVICE_START_PENDING; + dwState = SERVICE_RUNNING; break; case SERVICE_CONTROL_STOP: - dwPending = SERVICE_STOP_PENDING; - dwState = SERVICE_STOPPED; + dwPendingState = SERVICE_STOP_PENDING; + dwState = SERVICE_STOPPED; break; case SERVICE_CONTROL_PAUSE: - dwPending = SERVICE_PAUSE_PENDING; - dwState = SERVICE_PAUSED; + dwPendingState = SERVICE_PAUSE_PENDING; + dwState = SERVICE_PAUSED; break; default: break; @@ -468,27 +468,27 @@ apxServiceControl(APXHANDLE hService, DWORD dwControl, UINT uMsg, switch (dwControl & 0xE0) { case 0x80: case 0x90: - dwPending = SERVICE_START_PENDING; - dwState = SERVICE_RUNNING; + dwPendingState = SERVICE_START_PENDING; + dwState = SERVICE_RUNNING; break; case 0xA0: case 0xB0: - dwPending = SERVICE_STOP_PENDING; - dwState = SERVICE_STOPPED; + dwPendingState = SERVICE_STOP_PENDING; + dwState = SERVICE_STOPPED; break; case 0xC0: case 0xD0: - dwPending = SERVICE_PAUSE_PENDING; - dwState = SERVICE_PAUSED; + dwPendingState = SERVICE_PAUSE_PENDING; + dwState = SERVICE_PAUSED; break; default: break; } } - if (!dwPending && !dwState) { + if (!dwPendingState && !dwState) { apxLogWrite(APXLOG_MARK_ERROR - "apxServiceControl(): !dwPending(%d) && !dwState(%d); returning FALSE", - dwPending, + "apxServiceControl(): !dwPendingState(%d) && !dwState(%d); returning FALSE", + dwPendingState, dwState); return FALSE; } @@ -519,7 +519,7 @@ apxServiceControl(APXHANDLE hService, DWORD dwControl, UINT uMsg, if (bStatus) { Sleep(100); /* Initial Sleep period */ while (QueryServiceStatus(lpService->hService, &stStatus)) { - if (stStatus.dwCurrentState == dwPending) { + if (stStatus.dwCurrentState == dwPendingState) { /* Do not wait longer than the wait hint. A good interval is * one tenth the wait hint, but no less than 1 second and no * more than 10 seconds.
