You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2021/02/05 18:11:35 UTC

[GitHub] [commons-daemon] jfclere opened a new pull request #23: Fix for https://issues.apache.org/jira/browse/DAEMON-314

jfclere opened a new pull request #23:
URL: https://github.com/apache/commons-daemon/pull/23


   https://github.com/apache/commons-daemon/commit/5bca7af78162fbdd2d2f4b6b95470b29d15039a8 was the first part of fix.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [commons-daemon] garydgregory commented on a change in pull request #23: Fix for https://issues.apache.org/jira/browse/DAEMON-314

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #23:
URL: https://github.com/apache/commons-daemon/pull/23#discussion_r571185640



##########
File path: src/native/windows/src/service.c
##########
@@ -575,6 +575,57 @@ apxServiceControl(APXHANDLE hService, DWORD dwControl, UINT uMsg,
     return FALSE;
 }
 
+BOOL

Review comment:
       A comment here would be better. Think of folks reading the code in the future ;-)




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [commons-daemon] jfclere commented on a change in pull request #23: Fix for https://issues.apache.org/jira/browse/DAEMON-314

Posted by GitBox <gi...@apache.org>.
jfclere commented on a change in pull request #23:
URL: https://github.com/apache/commons-daemon/pull/23#discussion_r572647864



##########
File path: src/native/windows/src/service.c
##########
@@ -575,6 +575,57 @@ apxServiceControl(APXHANDLE hService, DWORD dwControl, UINT uMsg,
     return FALSE;
 }
 
+BOOL

Review comment:
       There are no comments in the whole file I would rather make another commit explaining each routine in the include.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [commons-daemon] garydgregory commented on a change in pull request #23: Fix for https://issues.apache.org/jira/browse/DAEMON-314

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #23:
URL: https://github.com/apache/commons-daemon/pull/23#discussion_r571186576



##########
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:
       We have an API that does this kind of logging in prunsrv, refactor and reuse?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [commons-daemon] garydgregory commented on a change in pull request #23: Fix for https://issues.apache.org/jira/browse/DAEMON-314

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org



[GitHub] [commons-daemon] jfclere merged pull request #23: Fix for https://issues.apache.org/jira/browse/DAEMON-314

Posted by GitBox <gi...@apache.org>.
jfclere merged pull request #23:
URL: https://github.com/apache/commons-daemon/pull/23


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [commons-daemon] jfclere commented on a change in pull request #23: Fix for https://issues.apache.org/jira/browse/DAEMON-314

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org