jfclere commented on a change in pull request #23:
URL: https://github.com/apache/commons-daemon/pull/23#discussion_r572649323



##########
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:
       API that does that? Where?




----------------------------------------------------------------
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]


Reply via email to