From f5fb9fe068d118caee768950d77d0a6f9f375904 Mon Sep 17 00:00:00 2001
From: Copilot <198982749+Copilot@users.noreply.github.com>
Date: Thu, 02 Apr 2026 13:37:45 +0000
Subject: [PATCH] Fix Windows service start timeout (NET HELPMSG 3523) in doStartApplication (#621)
---
opendj-server-legacy/src/build-tools/windows/service.c | 19 +++++++++++++++++--
.github/workflows/build.yml | 2 ++
opendj-server-legacy/src/build-tools/windows/service.h | 2 ++
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 17a6361..e1809fa 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -247,9 +247,11 @@
opendj-server-legacy\target\package\opendj\bat\stop-ds.bat
opendj-server-legacy\target\package\opendj\bat\windows-service.bat --enableService
net start "OpenDJ Server"
+ if ($LASTEXITCODE -ne 0) { throw "net start 'OpenDJ Server' failed with exit code $LASTEXITCODE" }
for ($i=0; $i -lt 12; $i++) { try { $c = New-Object System.Net.Sockets.TcpClient('localhost', 1636); $c.Close(); break } catch { Start-Sleep -Seconds 5 } }
opendj-server-legacy\target\package\opendj\bat\ldapsearch.bat --hostname localhost --port 1636 --bindDN "cn=Directory Manager" --bindPassword password --useSsl --trustAll --baseDN "dc=example2,dc=com" --searchScope sub "(uid=user.*)" dn | find /c '"dn:"' | findstr "10000"
net stop "OpenDJ Server"
+ if ($LASTEXITCODE -ne 0) { throw "net stop 'OpenDJ Server' failed with exit code $LASTEXITCODE" }
opendj-server-legacy\target\package\opendj\bat\windows-service.bat --disableService
- name: Upload Windows exe artifacts
diff --git a/opendj-server-legacy/src/build-tools/windows/service.c b/opendj-server-legacy/src/build-tools/windows/service.c
index 166853b..d14eaa4 100644
--- a/opendj-server-legacy/src/build-tools/windows/service.c
+++ b/opendj-server-legacy/src/build-tools/windows/service.c
@@ -503,7 +503,7 @@
// The functions returns SERVICE_RETURN_OK if we could start the server
// and SERVICE_RETURN_ERROR otherwise.
// ----------------------------------------------------
-ServiceReturnCode doStartApplication()
+ServiceReturnCode doStartApplication(SERVICE_STATUS_HANDLE *serviceStatusHandle, DWORD *checkPoint)
{
ServiceReturnCode returnValue;
// init out params
@@ -546,6 +546,11 @@
debug("doStartApplication: OPENDJ_WINDOWS_SERVICE_STARTDS_WAIT is not set. Using default %d milliseconds.",
STARTDS_WAIT_DEFAULT_VALUE);
}
+ if (serviceStatusHandle != NULL && checkPoint != NULL)
+ {
+ updateServiceStatus(SERVICE_START_PENDING, NO_ERROR, 0,
+ (*checkPoint)++, wait + 30000, serviceStatusHandle);
+ }
waitOk = waitForProcess(&procInfo, wait, &startDSExit);
if (waitOk)
{
@@ -590,6 +595,11 @@
while ((nTries > 0) && !running)
{
nTries--;
+ if (serviceStatusHandle != NULL && checkPoint != NULL)
+ {
+ updateServiceStatus(SERVICE_START_PENDING, NO_ERROR, 0,
+ (*checkPoint)++, 10000, serviceStatusHandle);
+ }
if (isServerRunning(&running, TRUE) != SERVICE_RETURN_OK)
{
break;
@@ -640,6 +650,11 @@
while ((nTries > 0) && !running)
{
nTries--;
+ if (serviceStatusHandle != NULL && checkPoint != NULL)
+ {
+ updateServiceStatus(SERVICE_START_PENDING, NO_ERROR, 0,
+ (*checkPoint)++, 10000, serviceStatusHandle);
+ }
if (isServerRunning(&running, TRUE) != SERVICE_RETURN_OK)
{
break;
@@ -1119,7 +1134,7 @@
{
WORD argCount = 1;
const char *argc[] = {_instanceDir};
- code = doStartApplication();
+ code = doStartApplication(_serviceStatusHandle, &checkPoint);
switch (code)
{
diff --git a/opendj-server-legacy/src/build-tools/windows/service.h b/opendj-server-legacy/src/build-tools/windows/service.h
index 6d6b933..d75deba 100644
--- a/opendj-server-legacy/src/build-tools/windows/service.h
+++ b/opendj-server-legacy/src/build-tools/windows/service.h
@@ -13,6 +13,7 @@
*
* Copyright 2008 Sun Microsystems, Inc.
* Portions Copyright 2013 ForgeRock AS.
+ * Portions Copyright 2026 3A Systems, LLC.
*/
#include "common.h"
@@ -95,6 +96,7 @@
DWORD waitHint,
SERVICE_STATUS_HANDLE *serviceStatusHandle
);
+ServiceReturnCode doStartApplication(SERVICE_STATUS_HANDLE *serviceStatusHandle, DWORD *checkPoint);
void serviceHandler(DWORD controlCode);
BOOL getServiceStatus(char *serviceName, LPDWORD returnState);
--
Gitblit v1.10.0