commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1024281 - /commons/proper/daemon/trunk/src/native/windows/apps/prunsrv/prunsrv.c
Date Tue, 19 Oct 2010 15:39:47 GMT
Author: mturk
Date: Tue Oct 19 15:39:47 2010
New Revision: 1024281

URL: http://svn.apache.org/viewvc?rev=1024281&view=rev
Log:
Report service status with out shutdown hook. The threads are way gone by now.

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

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=1024281&r1=1024280&r2=1024281&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 Tue Oct 19 15:39:47
2010
@@ -799,6 +799,14 @@ BOOL child_callback(APXHANDLE hObject, U
     return TRUE;
 }
 
+static int onExitHook(void)
+{
+    apxLogWrite(APXLOG_MARK_DEBUG "On exit hook called ...");
+    reportServiceStatus(SERVICE_STOPPED, NO_ERROR, 0);
+    Sleep(1000);
+    return 0;    
+}
+
 /* Executed when the service receives stop event */
 static DWORD WINAPI serviceStop(LPVOID lpParameter)
 {
@@ -839,12 +847,19 @@ static DWORD WINAPI serviceStop(LPVOID l
         gSargs.szStdErrFilename = NULL;
         gSargs.szStdOutFilename = NULL;
 
+        if (lstrcmpA(_jni_sclass, "java/lang/System") == 0)
+            _onexit(onExitHook);
         /* Create sutdown event */
         gShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
         if (!apxJavaStart(&gSargs)) {
             apxLogWrite(APXLOG_MARK_ERROR "Failed starting java");
             rv = 3;
         }
+        else if (lstrcmpA(_jni_sclass, "java/lang/System") == 0) {
+            reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 5000);
+            apxLogWrite(APXLOG_MARK_DEBUG "Forcing java jni System.exit worker to finish...");
+            return 0;
+        }
         else {
             apxLogWrite(APXLOG_MARK_DEBUG "Waiting for java jni stop worker to finish...");
             apxJavaWait(hWorker, INFINITE, FALSE);



Mime
View raw message