From 2210a0de16da5c6bde80893e61725ec23c3ac36b Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Tue, 28 Jul 2026 14:25:48 +0000
Subject: [PATCH] [#768] Fix winlauncher.exe stop reporting success without stopping the server (#772)
---
.github/workflows/build.yml | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8691a0e..1767f9a 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -287,6 +287,21 @@
- name: Test on Windows
if: runner.os == 'Windows'
run: |
+ # Verify a stop took effect before moving on: wait until the server
+ # releases the exclusive byte-range lock it holds on locks\server.lock.
+ # The explicit Lock(0, 1) probe is required: a byte-range lock does not
+ # prevent opening the file, so a bare Open() would always succeed.
+ function Wait-ServerStopped($lockFile) {
+ $lockFile = Join-Path $PWD $lockFile
+ for ($i = 0; $i -lt 30; $i++) {
+ if (-not (Test-Path $lockFile)) { return }
+ try {
+ $fs = [System.IO.File]::Open($lockFile, 'Open', 'ReadWrite', 'ReadWrite')
+ try { $fs.Lock(0, 1); $fs.Unlock(0, 1); return } finally { $fs.Close() }
+ } catch { Start-Sleep -Seconds 2 }
+ }
+ throw "The server still holds the lock on ${lockFile}: the stop did not take effect"
+ }
set OPENDJ_JAVA_ARGS="-server -Xmx512m"
opendj-server-legacy\target\package\opendj\setup.bat -h localhost -p 1389 --ldapsPort 1636 --adminConnectorPort 4444 --enableStartTLS --generateSelfSignedCertificate --rootUserDN "cn=Directory Manager" --rootUserPassword password --baseDN dc=example,dc=com --sampleData 5000 --cli --acceptLicense --no-prompt
opendj-server-legacy\target\package\opendj\bat\status.bat --hostname localhost --bindDN "cn=Directory Manager" --bindPassword password --trustAll
@@ -325,6 +340,8 @@
opendj-server-legacy\target\package\opendj\bat\dsconfig.bat create-backend --hostname localhost --port 4444 --bindDN "cn=Directory Manager" --bindPassword password --backend-name=example2 --type je --set=base-dn:dc=example2,dc=com --set=enabled:true --no-prompt --trustAll
opendj-server-legacy\target\package\opendj\bat\makeldif.bat -o test.ldif -c suffix=dc=example2,dc=com opendj-server-legacy\target\package\opendj\config\MakeLDIF\example.template
opendj-server-legacy\target\package\opendj\bat\stop-ds.bat
+ if ($LASTEXITCODE -ne 0) { throw "stop-ds.bat failed with exit code $LASTEXITCODE" }
+ Wait-ServerStopped 'opendj-server-legacy\target\package\opendj\locks\server.lock'
echo "4.9.9.0" > opendj-server-legacy\target\package\opendj\config\buildinfo
opendj-server-legacy\target\package\opendj\upgrade.bat
opendj-server-legacy\target\package\opendj\bat\import-ldif.bat --offline --ldifFile test.ldif --backendID=example2
@@ -333,6 +350,8 @@
opendj-server-legacy\target\package\opendj\bat\rebuild-index.bat --bindDN "cn=Directory Manager" --bindPassword password --baseDN "dc=example2,dc=com" --rebuildAll --trustAll
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"
opendj-server-legacy\target\package\opendj\bat\stop-ds.bat
+ if ($LASTEXITCODE -ne 0) { throw "stop-ds.bat failed with exit code $LASTEXITCODE" }
+ Wait-ServerStopped 'opendj-server-legacy\target\package\opendj\locks\server.lock'
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" }
--
Gitblit v1.10.0