commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-commons/daemon/src/native/nt/procrun/src javajni.c
Date Sat, 25 Sep 2004 14:25:30 GMT
mturk       2004/09/25 07:25:30

  Modified:    daemon/src/native/nt/procrun/apps/prunsrv prunsrv.c
                        prunsrv.rc
               daemon/src/native/nt/procrun/include javajni.h
               daemon/src/native/nt/procrun/src javajni.c
  Log:
  Fix console handler for jni. Now we register -Xrs only for service
  mode, so that CTRL+BREAK dumps the thread.
  
  Revision  Changes    Path
  1.10      +11 -6     jakarta-commons/daemon/src/native/nt/procrun/apps/prunsrv/prunsrv.c
  
  Index: prunsrv.c
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/daemon/src/native/nt/procrun/apps/prunsrv/prunsrv.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- prunsrv.c	19 Sep 2004 08:48:28 -0000	1.9
  +++ prunsrv.c	25 Sep 2004 14:25:30 -0000	1.10
  @@ -740,7 +740,7 @@
               return 1;
           }
           if (!apxJavaInitialize(hWorker, _jni_classpath, _jni_jvmoptions,
  -                               SO_JVMMS, SO_JVMMX, SO_JVMSS)) {
  +                               SO_JVMMS, SO_JVMMX, SO_JVMSS, TRUE)) {
               rv = 2;
               apxLogWrite(APXLOG_MARK_ERROR "Failed initializing java %s", _jni_classpath);
               goto cleanup;
  @@ -887,7 +887,7 @@
               return 1;
           }
           if (!apxJavaInitialize(gWorker, _jni_classpath, _jni_jvmoptions,
  -                               SO_JVMMS, SO_JVMMX, SO_JVMSS)) {
  +                               SO_JVMMS, SO_JVMMX, SO_JVMSS, _service_mode)) {
               rv = 2;
               apxLogWrite(APXLOG_MARK_ERROR "Failed initializing java %s", _jni_classpath);
               goto cleanup;
  @@ -996,8 +996,12 @@
       switch (dwCtrlType) {
           case CTRL_BREAK_EVENT:
               apxLogWrite(APXLOG_MARK_INFO "Console CTRL+BREAK event signaled");
  -            serviceStop();
  -            return TRUE;
  +            if (_service_mode) {
  +                serviceStop();
  +                return TRUE;
  +            }
  +            else
  +                return FALSE;
           case CTRL_C_EVENT:
               apxLogWrite(APXLOG_MARK_INFO "Console CTRL+C event signaled");
               serviceStop();
  @@ -1104,6 +1108,9 @@
           DWORD rv;
           reportServiceStatus(SERVICE_RUNNING, NO_ERROR, 0);
           apxLogWrite(APXLOG_MARK_DEBUG "Waitning worker to finish...");
  +        /* Set console handler to capture CTRL events */
  +        SetConsoleCtrlHandler((PHANDLER_ROUTINE)console_handler, TRUE);
  +
           rv = apxHandleWait(gWorker, INFINITE, FALSE);
           apxLogWrite(APXLOG_MARK_DEBUG "Worker finished.");
           reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
  @@ -1180,8 +1187,6 @@
           rv = 2;
           goto cleanup;
       }
  -    /* Set console handler to capture CTRL events */
  -    SetConsoleCtrlHandler((PHANDLER_ROUTINE)console_handler, TRUE);
   
       apxLogOpen(gPool, SO_LOGPATH, SO_LOGPREFIX);
       apxLogLevelSetW(NULL, SO_LOGLEVEL);
  
  
  
  1.2       +2 -2      jakarta-commons/daemon/src/native/nt/procrun/apps/prunsrv/prunsrv.rc
  
  Index: prunsrv.rc
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/daemon/src/native/nt/procrun/apps/prunsrv/prunsrv.rc,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- prunsrv.rc	7 Apr 2004 11:21:43 -0000	1.1
  +++ prunsrv.rc	25 Sep 2004 14:25:30 -0000	1.2
  @@ -21,8 +21,8 @@
   IDI_MAINICON         ICON                   "../../resources/procrunw.ico" 
   
   1 VERSIONINFO
  - FILEVERSION 1,0,0,0
  - PRODUCTVERSION 1,0,0,0
  + FILEVERSION 2,0,0,0
  + PRODUCTVERSION 2,0,0,0
    FILEFLAGSMASK 0x3fL
   #if defined(_DEBUG)
    FILEFLAGS 0x03L
  
  
  
  1.2       +1 -1      jakarta-commons/daemon/src/native/nt/procrun/include/javajni.h
  
  Index: javajni.h
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/daemon/src/native/nt/procrun/include/javajni.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- javajni.h	7 Apr 2004 11:23:46 -0000	1.1
  +++ javajni.h	25 Sep 2004 14:25:30 -0000	1.2
  @@ -22,7 +22,7 @@
   
   BOOL        apxJavaInitialize(APXHANDLE hJava, LPCSTR szClassPath,
                                 LPCVOID lpOptions, DWORD dwMs, DWORD dwMx,
  -                              DWORD dwSs);
  +                              DWORD dwSs, BOOL bReduceSignals);
   
   BOOL        apxJavaLoadMainClass(APXHANDLE hJava, LPCSTR szClassName,
                                    LPCSTR szMethodName,
  
  
  
  1.5       +12 -12    jakarta-commons/daemon/src/native/nt/procrun/src/javajni.c
  
  Index: javajni.c
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/daemon/src/native/nt/procrun/src/javajni.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- javajni.c	19 Sep 2004 08:47:22 -0000	1.4
  +++ javajni.c	25 Sep 2004 14:25:30 -0000	1.5
  @@ -302,11 +302,7 @@
       jint rv;
       CHAR sBuf[1024+16];
       rv = wvsprintfA(sBuf, format, args);
  -#ifdef _DEBUG_JNI
  -    SetLastError(ERROR_SUCCESS);
  -    apxDisplayError(TRUE, NULL, 0, sBuf);
  -#endif
  -    apxLogWrite(APXLOG_MARK_INFO "JNI %s", sBuf);
  +    apxLogWrite(APXLOG_MARK_INFO "%s", sBuf);
       return rv;
   }
    
  @@ -315,13 +311,13 @@
   BOOL
   apxJavaInitialize(APXHANDLE hJava, LPCSTR szClassPath,
                     LPCVOID lpOptions, DWORD dwMs, DWORD dwMx,
  -                  DWORD dwSs)
  +                  DWORD dwSs, BOOL bReduceSignals)
   {
       LPAPXJAVAVM     lpJava;
       JDK1_1InitArgs  vmArgs11;
       JavaVMInitArgs  vmArgs; 
       JavaVMOption    *lpJvmOptions;
  -    DWORD           i, nOptions, sOptions = 3;
  +    DWORD           i, nOptions, sOptions = 2;
       BOOL            rv = FALSE;
       if (hJava->dwType != APXHANDLE_TYPE_JVM)
           return FALSE;
  @@ -373,16 +369,20 @@
               ++sOptions;
           if (dwSs)
               ++sOptions;
  +        if (bReduceSignals)
  +            ++sOptions;
           nOptions = __apxMultiSzToJvmOptions(hJava->hPool, lpOptions,
                                               &lpJvmOptions, sOptions);
           szCp = apxPoolAlloc(hJava->hPool, sizeof(JAVA_CLASSPATH) + lstrlenA(szClassPath));
           lstrcpyA(szCp, JAVA_CLASSPATH);
           lstrcatA(szCp, szClassPath);
  -        /* reduce signals by default to skip registering console
  -         * control handler
  -         */
  -        lpJvmOptions[nOptions - sOptions].optionString = "-Xrs";
  -        --sOptions;
  +        if (bReduceSignals) {
  +            /* reduce signals to skip registering console
  +             * control handler
  +             */
  +            lpJvmOptions[nOptions - sOptions].optionString = "-Xrs";
  +            --sOptions;
  +        }
           lpJvmOptions[nOptions - sOptions].optionString = szCp;
           --sOptions;
           /* default JNI error printer */
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message