commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r909084 - in /commons/proper/daemon/trunk/src/native/nt/procrun: apps/prunmgr/prunmgr.c apps/prunsrv/prunsrv.c include/javajni.h src/javajni.c
Date Thu, 11 Feb 2010 17:20:43 GMT
Author: mturk
Date: Thu Feb 11 17:20:29 2010
New Revision: 909084

URL: http://svn.apache.org/viewvc?rev=909084&view=rev
Log:
Fix DAEMON-96 by allowing 8K limit

Modified:
    commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunmgr/prunmgr.c
    commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c
    commons/proper/daemon/trunk/src/native/nt/procrun/include/javajni.h
    commons/proper/daemon/trunk/src/native/nt/procrun/src/javajni.c

Modified: commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunmgr/prunmgr.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunmgr/prunmgr.c?rev=909084&r1=909083&r2=909084&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunmgr/prunmgr.c (original)
+++ commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunmgr/prunmgr.c Thu Feb 11 17:20:29
2010
@@ -386,7 +386,7 @@
 
 BOOL __generalJvmSave(HWND hDlg)
 {
-    WCHAR szB[SIZ_DESLEN];
+    WCHAR szB[SIZ_HUGLEN];
     LPWSTR p, s;
     DWORD  l;
     if (!(TST_BIT_FLAG(_propertyChanged, 4)))
@@ -396,12 +396,12 @@
     if (IS_INVALID_HANDLE(hService))
         return FALSE;
     if (!IsDlgButtonChecked(hDlg, IDC_PPJAUTO)) {
-        GetDlgItemTextW(hDlg, IDC_PPJJVM,  szB, SIZ_DESMAX);
+        GetDlgItemTextW(hDlg, IDC_PPJJVM,  szB, SIZ_HUGMAX);
     }
     else
         lstrcpyW(szB, L"auto");
     apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_java, L"Jvm", szB);
-    GetDlgItemTextW(hDlg, IDC_PPJCLASSPATH,  szB, SIZ_DESMAX);
+    GetDlgItemTextW(hDlg, IDC_PPJCLASSPATH,  szB, SIZ_HUGMAX);
     apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_java, L"Classpath", szB);
 
     l = GetWindowTextLength(GetDlgItem(hDlg, IDC_PPJOPTIONS));
@@ -411,7 +411,7 @@
     apxFree(p);
     apxRegistrySetMzStrW(hRegserv, APXREG_PARAMSOFTWARE,
                          _s_java, L"Options", s, l);
-    if (!GetDlgItemTextW(hDlg, IDC_PPJMS,  szB, SIZ_DESMAX))
+    if (!GetDlgItemTextW(hDlg, IDC_PPJMS,  szB, SIZ_HUGMAX))
         szB[0] = L'\0';
 
     apxRegistrySetNumW(hRegserv, APXREG_PARAMSOFTWARE, _s_java, L"JvmMs",
@@ -432,7 +432,7 @@
 
 BOOL __generalStartSave(HWND hDlg)
 {
-    WCHAR szB[SIZ_DESLEN];
+    WCHAR szB[SIZ_HUGLEN];
     LPWSTR p, s;
     DWORD  l;
 
@@ -443,15 +443,15 @@
     if (IS_INVALID_HANDLE(hService))
         return FALSE;
 
-    GetDlgItemTextW(hDlg, IDC_PPRCLASS,  szB, SIZ_DESMAX);
+    GetDlgItemTextW(hDlg, IDC_PPRCLASS,  szB, SIZ_HUGMAX);
     apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"Class", szB);
-    GetDlgItemTextW(hDlg, IDC_PPRIMAGE,  szB, SIZ_DESMAX);
+    GetDlgItemTextW(hDlg, IDC_PPRIMAGE,  szB, SIZ_HUGMAX);
     apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"Image", szB);
-    GetDlgItemTextW(hDlg, IDC_PPRWPATH,  szB, SIZ_DESMAX);
+    GetDlgItemTextW(hDlg, IDC_PPRWPATH,  szB, SIZ_HUGMAX);
     apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"WorkingPath", szB);
-    GetDlgItemTextW(hDlg, IDC_PPRMETHOD,  szB, SIZ_DESMAX);
+    GetDlgItemTextW(hDlg, IDC_PPRMETHOD,  szB, SIZ_HUGMAX);
     apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"Method", szB);
-    GetDlgItemTextW(hDlg, IDC_PPRMODE,  szB, SIZ_DESMAX);
+    GetDlgItemTextW(hDlg, IDC_PPRMODE,  szB, SIZ_HUGMAX);
     apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"Mode", szB);
 
     l = GetWindowTextLength(GetDlgItem(hDlg, IDC_PPRARGS));
@@ -470,7 +470,7 @@
 
 BOOL __generalStopSave(HWND hDlg)
 {
-    WCHAR szB[SIZ_DESLEN];
+    WCHAR szB[SIZ_HUGLEN];
     LPWSTR p, s;
     DWORD  l;
 
@@ -481,17 +481,17 @@
     if (IS_INVALID_HANDLE(hService))
         return FALSE;
 
-    GetDlgItemTextW(hDlg, IDC_PPSCLASS,  szB, SIZ_DESMAX);
+    GetDlgItemTextW(hDlg, IDC_PPSCLASS,  szB, SIZ_HUGMAX);
     apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Class", szB);
-    GetDlgItemTextW(hDlg, IDC_PPSIMAGE,  szB, SIZ_DESMAX);
+    GetDlgItemTextW(hDlg, IDC_PPSIMAGE,  szB, SIZ_HUGMAX);
     apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Image", szB);
-    GetDlgItemTextW(hDlg, IDC_PPSWPATH,  szB, SIZ_DESMAX);
+    GetDlgItemTextW(hDlg, IDC_PPSWPATH,  szB, SIZ_HUGMAX);
     apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"WorkingPath", szB);
-    GetDlgItemTextW(hDlg, IDC_PPSMETHOD,  szB, SIZ_DESMAX);
+    GetDlgItemTextW(hDlg, IDC_PPSMETHOD,  szB, SIZ_HUGMAX);
     apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Method", szB);
-    GetDlgItemTextW(hDlg, IDC_PPSTIMEOUT,  szB, SIZ_DESMAX);
+    GetDlgItemTextW(hDlg, IDC_PPSTIMEOUT,  szB, SIZ_HUGMAX);
     apxRegistrySetNumW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Timeout", apxAtoulW(szB));
-    GetDlgItemTextW(hDlg, IDC_PPSMODE,  szB, SIZ_DESMAX);
+    GetDlgItemTextW(hDlg, IDC_PPSMODE,  szB, SIZ_HUGMAX);
     apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Mode", szB);
 
     l = GetWindowTextLength(GetDlgItem(hDlg, IDC_PPSARGS));

Modified: commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c?rev=909084&r1=909083&r2=909084&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c (original)
+++ commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c Thu Feb 11 17:20:29
2010
@@ -198,6 +198,10 @@
 static BOOL                  _jni_startup  = FALSE;
 /* JVM used for shutdown    */
 static BOOL                  _jni_shutdown = FALSE;
+/* Java used as worker       */
+static BOOL                  _java_startup  = FALSE;
+/* Java used for shutdown    */
+static BOOL                  _java_shutdown = FALSE;
 /* Global variables and objects */
 static APXHANDLE    gPool;
 static APXHANDLE    gWorker;
@@ -211,8 +215,8 @@
 static LPCWSTR  _jni_sparam               = NULL;    /* Shutdown arguments */
 static LPSTR    _jni_rmethod              = NULL;    /* Startup  arguments */
 static LPSTR    _jni_smethod              = NULL;    /* Shutdown arguments */
-static CHAR     _jni_rclass[SIZ_RESLEN]   = {'\0'};  /* Startup  class */
-static CHAR     _jni_sclass[SIZ_RESLEN]   = {'\0'};  /* Shutdown class */
+static CHAR     _jni_rclass[SIZ_HUGLEN]   = {'\0'};  /* Startup  class */
+static CHAR     _jni_sclass[SIZ_HUGLEN]   = {'\0'};  /* Shutdown class */
 
 static HANDLE gShutdownEvent = NULL;
 static HANDLE gSignalEvent   = NULL;
@@ -858,7 +862,15 @@
             goto cleanup;
         }
         /* Assemble the command line */
-        nArgs = apxMultiSzToArrayW(gPool, SO_STOPPARAMS, &pArgs);
+        if (_java_shutdown) {
+            nArgs = apxJavaCmdInitialize(gPool, SO_CLASSPATH, SO_STOPCLASS,
+                                         SO_JVMOPTIONS, SO_JVMMS, SO_JVMMX,
+                                         SO_JVMSS, SO_STOPPARAMS, &pArgs);
+        }
+        else {
+            nArgs = apxMultiSzToArrayW(gPool, SO_STOPPARAMS, &pArgs);
+        }
+
         /* Pass the argv to child process */
         if (!apxProcessSetCommandArgsW(hWorker, SO_STOPIMAGE,
                                        nArgs, pArgs)) {
@@ -1011,7 +1023,15 @@
             goto cleanup;
         }
         /* Assemble the command line */
-        nArgs = apxMultiSzToArrayW(gPool, SO_STARTPARAMS, &pArgs);
+        if (_java_startup) {
+            nArgs = apxJavaCmdInitialize(gPool, SO_CLASSPATH, SO_STARTCLASS,
+                                         SO_JVMOPTIONS, SO_JVMMS, SO_JVMMX,
+                                         SO_JVMSS, SO_STARTPARAMS, &pArgs);
+        }
+        else {
+            nArgs = apxMultiSzToArrayW(gPool, SO_STARTPARAMS, &pArgs);
+        }
+
         /* Pass the argv to child process */
         if (!apxProcessSetCommandArgsW(gWorker, SO_STARTIMAGE,
                                        nArgs, pArgs)) {
@@ -1144,7 +1164,7 @@
     apxLogWrite(APXLOG_MARK_DEBUG "Inside ServiceMain...");
 
     if (_service_name) {
-        WCHAR en[SIZ_DESLEN];
+        WCHAR en[SIZ_HUGLEN];
         int i;
         PSECURITY_ATTRIBUTES sa = GetNullACL();
         lstrlcpyW(en, SIZ_DESLEN, L"Global\\");
@@ -1185,6 +1205,7 @@
                 apxLogWrite(APXLOG_MARK_ERROR "Unable to find Java Runtime Environment.");
                 goto cleanup;
             }
+            _java_startup = TRUE;
             /* StartImage now contains the full path to the java.exe */
             SO_STARTIMAGE = jx;
         }
@@ -1211,6 +1232,7 @@
                 apxLogWrite(APXLOG_MARK_ERROR "Unable to find Java Runtime Environment.");
                 goto cleanup;
             }
+            _java_shutdown = TRUE;
             /* StopImage now contains the full path to the java.exe */
             SO_STOPIMAGE = jx;
         }

Modified: commons/proper/daemon/trunk/src/native/nt/procrun/include/javajni.h
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/nt/procrun/include/javajni.h?rev=909084&r1=909083&r2=909084&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/nt/procrun/include/javajni.h (original)
+++ commons/proper/daemon/trunk/src/native/nt/procrun/include/javajni.h Thu Feb 11 17:20:29
2010
@@ -24,6 +24,10 @@
 BOOL        apxJavaInitialize(APXHANDLE hJava, LPCSTR szClassPath,
                               LPCVOID lpOptions, DWORD dwMs, DWORD dwMx,
                               DWORD dwSs);
+DWORD
+apxJavaCmdInitialize(APXHANDLE hPool, LPCWSTR szClassPath, LPCWSTR szClass,
+                     LPCWSTR szOptions, DWORD dwMs, DWORD dwMx,
+                     DWORD dwSs, LPCWSTR szCmdArgs, LPWSTR **lppArray);
 
 BOOL        apxJavaLoadMainClass(APXHANDLE hJava, LPCSTR szClassName,
                                  LPCSTR szMethodName,

Modified: commons/proper/daemon/trunk/src/native/nt/procrun/src/javajni.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/nt/procrun/src/javajni.c?rev=909084&r1=909083&r2=909084&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/nt/procrun/src/javajni.c (original)
+++ commons/proper/daemon/trunk/src/native/nt/procrun/src/javajni.c Thu Feb 11 17:20:29 2010
@@ -122,6 +122,7 @@
 } APXJAVAVM, *LPAPXJAVAVM;
 
 #define JAVA_CLASSPATH      "-Djava.class.path="
+#define JAVA_CLASSPATH_W    L"-Djava.class.path="
 #define JAVA_CLASSSTRING    "java/lang/String"
 
 static __inline BOOL __apxJvmAttach(LPAPXJAVAVM lpJava)
@@ -445,6 +446,99 @@
     return FALSE;
 }
 
+/* ANSI version only */
+DWORD
+apxJavaCmdInitialize(APXHANDLE hPool, LPCWSTR szClassPath, LPCWSTR szClass,
+                     LPCWSTR szOptions, DWORD dwMs, DWORD dwMx,
+                     DWORD dwSs, LPCWSTR szCmdArgs, LPWSTR **lppArray)
+{
+
+    DWORD i, nJVM, nCmd, nTotal, lJVM, lCmd;
+    LPWSTR p;
+
+    // Calculate the number of all arguments
+    nTotal = 0;
+    if (szClassPath)
+        ++nTotal;
+    if (szClass)
+        ++nTotal;
+    lJVM = __apxGetMultiSzLengthW(szOptions, &nJVM);
+    nTotal += nJVM;
+    lCmd = __apxGetMultiSzLengthW(szCmdArgs, &nCmd);
+    nTotal += nCmd;
+    if (dwMs)
+        ++nTotal;
+    if (dwMx)
+        ++nTotal;
+    if (dwSs)
+        ++nTotal;
+
+    if (nTotal == 0)
+        return 0;
+
+    // Allocate the array to store all arguments' pointers
+    *lppArray = (LPWSTR *)apxPoolAlloc(hPool, (nTotal + 2) * sizeof(LPWSTR));
+
+    // Process JVM options
+    if (nJVM && lJVM) {
+        p = (LPWSTR)apxPoolAlloc(hPool, (lJVM + 1) * sizeof(WCHAR));
+        AplCopyMemory(p, szOptions, (lJVM + 1) * sizeof(WCHAR) + sizeof(WCHAR));
+        for (i = 0; i < nJVM; i++) {
+            (*lppArray)[i] = p;
+            while (*p)
+                p++;
+            p++;
+        }
+    }
+
+    // Process the 3 extra JVM options
+    if (dwMs) {
+        p = (LPWSTR)apxPoolAlloc(hPool, 64 * sizeof(WCHAR));
+        wsprintfW(p, L"-Xms%dm", dwMs);
+        (*lppArray)[i++] = p;
+    }
+    if (dwMx) {
+        p = (LPWSTR)apxPoolAlloc(hPool, 64 * sizeof(WCHAR));
+        wsprintfW(p, L"-Xmx%dm", dwMx);
+        (*lppArray)[i++] = p;
+    }
+    if (dwSs) {
+        p = (LPWSTR)apxPoolAlloc(hPool, 64 * sizeof(WCHAR));
+        wsprintfW(p, L"-Xss%dk", dwSs);
+        (*lppArray)[i++] = p;
+    }
+
+    // Process the classpath and class
+    if (szClassPath) {
+        p = (LPWSTR)apxPoolAlloc(hPool, (lstrlenW(JAVA_CLASSPATH_W) + lstrlenW(szClassPath))
* sizeof(WCHAR));
+        lstrcpyW(p, JAVA_CLASSPATH_W);
+        lstrcatW(p, szClassPath);
+        (*lppArray)[i++] = p;
+    }
+    if (szClass) {
+        p = (LPWSTR)apxPoolAlloc(hPool, (lstrlenW(szClass)) * sizeof(WCHAR));
+        lstrcpyW(p, szClass);
+        (*lppArray)[i++] = p;
+    }
+
+    // Process command arguments
+    if (nCmd && lCmd) {
+        p = (LPWSTR)apxPoolAlloc(hPool, (lCmd + 1) * sizeof(WCHAR));
+        AplCopyMemory(p, szCmdArgs, (lCmd + 1) * sizeof(WCHAR) + sizeof(WCHAR));
+        for (; i < nTotal; i++) {
+            (*lppArray)[i] = p;
+            while (*p)
+                p++;
+            p++;
+        }
+    }
+
+    (*lppArray)[++i] = NULL;
+
+    return nTotal;
+}
+
+
 BOOL
 apxJavaLoadMainClass(APXHANDLE hJava, LPCSTR szClassName,
                      LPCSTR szMethodName,
@@ -809,3 +903,4 @@
         return TRUE;
 
 }
+



Mime
View raw message