garydgregory commented on a change in pull request #23:
URL: https://github.com/apache/commons-daemon/pull/23#discussion_r572941782
##########
File path: src/native/windows/src/service.c
##########
@@ -575,6 +575,57 @@ apxServiceControl(APXHANDLE hService, DWORD dwControl,
UINT uMsg,
return FALSE;
}
+BOOL
+apxServiceCheckStop(APXHANDLE hService)
+{
+ LPAPXSERVICE lpService;
+ SERVICE_STATUS stStatus;
+ DWORD dwState = SERVICE_STOPPED;
+ DWORD sleepMillis;
+
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return FALSE;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode) {
+ apxLogWrite(APXLOG_MARK_ERROR "apxServiceCheck(): Manager mode cannot
handle services, returning FALSE");
+ return FALSE;
+ }
+ /* Check if the ServiceOpen has been called */
+ if (IS_INVALID_HANDLE(lpService->hService)) {
+ apxLogWrite(APXLOG_MARK_ERROR "apxServiceCheck(): Service is not open,
returning FALSE");
+ return FALSE;
+ }
+
+ /* Check if we are in the stopped state */
+ sleepMillis = 1000;
+ apxLogWrite(APXLOG_MARK_DEBUG "apxServiceCheck(): Sleeping %d
milliseconds", sleepMillis);
+ Sleep(sleepMillis);
+
+ if (QueryServiceStatus(lpService->hService, &stStatus)) {
+ apxLogWrite(APXLOG_MARK_DEBUG "apxServiceCheck(): QueryServiceStatus
OK");
+ if (stStatus.dwCurrentState == dwState) {
+ return TRUE;
+ } else {
+ apxLogWrite(APXLOG_MARK_DEBUG
Review comment:
Never mind; on 2nd, thought it is not be worth refactoring the call to
apxLogWrite() in reportServiceStatusE(), since the message format here is a
little different.
##########
File path: src/native/windows/src/service.c
##########
@@ -575,6 +575,57 @@ apxServiceControl(APXHANDLE hService, DWORD dwControl,
UINT uMsg,
return FALSE;
}
+BOOL
Review comment:
Nope, if YOU add a function/method, then YOU should document. Then, if
you feel like documenting existing code, you can do that as well.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]