mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

copilot-swe-agent[bot]
5 days ago 6dafd327020e6e04fa688d61ca5f21835817bb04
Fix Windows service start timeout (NET HELPMSG 3523) by updating SCM checkpoints in doStartApplication

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenDJ/sessions/03d09be5-2d85-4bc6-8120-3ecaf02fe51d

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
2 files modified
21 ■■■■■ changed files
opendj-server-legacy/src/build-tools/windows/service.c 19 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/build-tools/windows/service.h 2 ●●●●● patch | view | raw | blame | history
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)
    {
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);