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 2ed8dc0 Fix DAEMON-475
2ed8dc0 is described below
commit 2ed8dc0a93a901ac780fcd60540d9bdc404297f4
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Nov 17 12:38:18 2025 +0000
Fix DAEMON-475
---
src/changes/changes.xml | 1 +
src/native/windows/apps/prunsrv/prunsrv.c | 33 ++++++++++++++++++-------------
2 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c882d33..690c6db 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,7 @@
<action type="fix" issue="DAEMON-398" dev="jfclere">Fix redirection
issues on some OS versions by using recommended method to redirect stdout and
stderr</action>
<action type="fix" issue="DAEMON-468" dev="ggregory"
due-to="Jean-Frederic Clere, Mark Thomas, Sebb, Gary Gregory">Fix timeout
handling in procrun #238.</action>
<action type="fix" issue="DAEMON-472" dev="markt">Replace RTF version of
license header with plain text version of full license in about box for Procrun
monitor application.</action>
+ <action type="fix" issue="DAEMON-475" dev="markt">Service should be
marked as stopped if the service worker crashes.</action>
<!-- ADD -->
<action type="add" dev="michaelo" issue="DAEMON-471">Add support for
--enable-native-access Java startup option in jsvc.</action>
<action type="add" dev="ggregory" due-to="Jean-Frederic Clere, Gary
Gregory, Mark Thomas">Add tests for prunsrv on Windows #260.</action>
diff --git a/src/native/windows/apps/prunsrv/prunsrv.c
b/src/native/windows/apps/prunsrv/prunsrv.c
index 3c9ba8d..53fe043 100644
--- a/src/native/windows/apps/prunsrv/prunsrv.c
+++ b/src/native/windows/apps/prunsrv/prunsrv.c
@@ -1921,23 +1921,28 @@ void WINAPI serviceMain(DWORD argc, LPTSTR *argv)
DWORD count = 0;
/* wait 2 seconds */
DWORD rv = apxHandleWait(gWorker, 2000, FALSE);
- if (rv == WAIT_OBJECT_0 && !_exe_shutdown) {
- if (!bLoopWarningIssued) {
- apxLogWrite(APXLOG_MARK_WARN "Start method returned
before stop method was called. This should not happen. Using loop with a fixed
sleep of 2 seconds waiting for stop method to be called.");
- bLoopWarningIssued = TRUE;
- }
- /* XXXX apart error are we getting there??? */
- Sleep(2000);
- count = count + 2;
- if (count >= SO_STOPTIMEOUT) {
- apxLogWrite(APXLOG_MARK_WARN "waited %d sec, Timeout
reached!" , count);
+ if (rv == WAIT_OBJECT_0 && _exe_shutdown) {
+ /* Normal exit. NO-OP */
+ } else if (rv != WAIT_OBJECT_0 && !_exe_shutdown)) {
+ /* Normal running. */
+ apxLogWrite(APXLOG_MARK_DEBUG "waiting until Worker is
done...");
+ } else if (rv == WAIT_OBJECT_0 && !_exe_shutdown) {
+ if (_jni_started) {
+ /* JNI mode not being used correctly */
+ if (!bLoopWarningIssued) {
+ apxLogWrite(APXLOG_MARK_WARN "Start method
returned before stop method was called. This should not happen. Using loop with
a fixed sleep of 2 seconds waiting for stop method to be called.");
+ bLoopWarningIssued = TRUE;
+ }
+ Sleep(2000);
+ } else {
+ /* Non-JNI mode has crashed */
+ apxLogWrite(APXLOG_MARK_ERROR "Service '%S' has
terminated abnormally.", _service_name);
break;
}
+ } else if (rv != WAIT_OBJECT_0 && _exe_shutdown)) {
+ /* Stop has been called but service worker has not yet
stopped. */
+ /* do ... while loop will exit and stop timeout will be
processed. */
}
- if (rv == WAIT_OBJECT_0)
- apxLogWrite(APXLOG_MARK_WARN "Worker has crashed or
stopped!");
- else
- apxLogWrite(APXLOG_MARK_DEBUG "waiting until Worker is
done...");
} while (!_exe_shutdown);
/* calculate remaing timeout */