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 2017/10/20 20:33:20 UTC

svn commit: r1812789 - in /commons/proper/daemon/trunk/src: changes/changes.xml native/windows/apps/prunsrv/prunsrv.c

Author: markt
Date: Fri Oct 20 20:33:20 2017
New Revision: 1812789

URL: http://svn.apache.org/viewvc?rev=1812789&view=rev
Log:
Fix DAEMON-372
Ensure that, when using procrun in java or exe mode, the service process waits for the stop process to complete before starting clean-up to avoid a crash in the stop process.
This closes #4

Modified:
    commons/proper/daemon/trunk/src/changes/changes.xml
    commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c

Modified: commons/proper/daemon/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/changes/changes.xml?rev=1812789&r1=1812788&r2=1812789&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/changes/changes.xml (original)
+++ commons/proper/daemon/trunk/src/changes/changes.xml Fri Oct 20 20:33:20 2017
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements. See the NOTICE file distributed with
@@ -99,6 +99,11 @@
         Correct conflicting information for the behaviour of procrun when using
         jvm mode.
       </action>
+      <action issue="DAEMON-372" type="fix" dev="markt" due-to="Sérgio Ozaki">
+        Ensure that, when using procrun in java or exe mode, the service process
+        waits for the stop process to complete before starting clean-up to avoid
+        a crash in the stop process. 
+      </action>
     </release>
   </body>
 </document>

Modified: commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c?rev=1812789&r1=1812788&r2=1812789&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c (original)
+++ commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c Fri Oct 20 20:33:20 2017
@@ -1016,6 +1016,12 @@ static DWORD WINAPI serviceStop(LPVOID l
             apxLogWrite(APXLOG_MARK_ERROR "Failed creating process");
             return 1;
         }
+        /* If the service process completes before the stop process does the
+         * cleanup code below will free structures required by the stop process
+         * which will, in all probability, trigger a crash. Wait for the stop
+         * process to complete before cleaning up.
+         */
+        gShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
         if (!apxProcessSetExecutableW(hWorker, SO_STOPIMAGE)) {
             apxLogWrite(APXLOG_MARK_ERROR "Failed setting process executable %S",
                         SO_STOPIMAGE);