You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2022/03/10 20:45:04 UTC

[commons-daemon] branch master updated: Fix DAEMON-439. Support --Startup=delayed on installation

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-daemon.git


The following commit(s) were added to refs/heads/master by this push:
     new 3efc0a7  Fix DAEMON-439. Support --Startup=delayed on installation
3efc0a7 is described below

commit 3efc0a73289d9a221f9f6e832ba3e06c90ab9a00
Author: Administrator <Ad...@win-2022-dev.homeinbox.net>
AuthorDate: Thu Mar 10 20:44:57 2022 +0000

    Fix DAEMON-439. Support --Startup=delayed on installation
    
    It was supported on update but not on installation.
---
 src/changes/changes.xml                   |  4 ++++
 src/native/windows/apps/prunsrv/prunsrv.c | 24 ++++++++++++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7e85426..1e978d9 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -75,6 +75,10 @@
         Procrun. Ensure Trace is included in the logging levels exposed in the
         GUI.
       </action>
+      <action issue="DAEMON-439" type="fix" dev="markt">
+        Procrun. Support --Startup=delayed for service installaion as well as
+        service update.
+      </action>
       <!-- ADD -->
       <action type="add" dev="ggregory" due-to="John Patrick">
         Enable Dependabot #20.
diff --git a/src/native/windows/apps/prunsrv/prunsrv.c b/src/native/windows/apps/prunsrv/prunsrv.c
index 1f607be..49e1b52 100644
--- a/src/native/windows/apps/prunsrv/prunsrv.c
+++ b/src/native/windows/apps/prunsrv/prunsrv.c
@@ -725,6 +725,7 @@ static BOOL docmdInstallService(LPAPXCMDLINE lpCmdline)
 {
     APXHANDLE hService;
     BOOL  rv;
+    BOOL  bDelayedStart = FALSE;
     DWORD dwStart = SERVICE_DEMAND_START;
     DWORD dwType  = SERVICE_WIN32_OWN_PROCESS;
     WCHAR szImage[SIZ_HUGLEN];
@@ -737,9 +738,14 @@ static BOOL docmdInstallService(LPAPXCMDLINE lpCmdline)
         return FALSE;
     }
     /* Check the startup mode */
-    if ((ST_STARTUP & APXCMDOPT_FOUND) &&
-        lstrcmpiW(SO_STARTUP, PRSRV_AUTO) == 0)
-        dwStart = SERVICE_AUTO_START;
+    if (ST_STARTUP & APXCMDOPT_FOUND) {
+    	if (lstrcmpiW(SO_STARTUP, PRSRV_AUTO) == 0) {
+    		dwStart = SERVICE_AUTO_START;
+    	} else if (lstrcmpiW(SO_STARTUP, PRSRV_DELAYED) == 0) {
+    		dwStart = SERVICE_AUTO_START;
+    		bDelayedStart = TRUE;
+    	}
+    }
     /* Check the service type */
     if ((ST_TYPE & APXCMDOPT_FOUND) &&
         lstrcmpiW(SO_TYPE, STYPE_INTERACTIVE) == 0) {
@@ -791,6 +797,16 @@ static BOOL docmdInstallService(LPAPXCMDLINE lpCmdline)
                           SO_DEPENDSON,      /* --DependendsOn */
                           dwType,
                           dwStart);
+    /* Configure as delayed start */
+    if (rv & bDelayedStart) {
+    	if (!apxServiceSetOptions(hService,
+                                  dwType,
+                                  dwStart,
+                                  bDelayedStart,
+                                  SERVICE_NO_CHANGE)) {
+            apxLogWrite(APXLOG_MARK_WARN "Failed to configure service for delayed startup");
+        }
+    }
     /* Set the --Description */
     if (rv) {
         LPCWSTR sd = NULL;
@@ -1014,7 +1030,7 @@ static BOOL docmdUpdateService(LPAPXCMDLINE lpCmdline)
         /* Update the --Startup mode */
         if (ST_STARTUP & APXCMDOPT_FOUND) {
             if (!lstrcmpiW(SO_STARTUP, PRSRV_DELAYED)) {
-                dwStart = SERVICE_AUTO_START;
+                dwStart = SERVICE_DEMAND_START;
                 bDelayedStart = TRUE;
             }
             else if (!lstrcmpiW(SO_STARTUP, PRSRV_AUTO))