[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-dev
Subject: svn commit: r1098094 - in /commons/sandbox/runtime/trunk: build.xml
From: mturk () apache ! org
Date: 2011-04-30 10:27:03
Message-ID: 20110430102703.EFA9B2388A19 () eris ! apache ! org
[Download RAW message or body]
Author: mturk
Date: Sat Apr 30 10:27:03 2011
New Revision: 1098094
URL: http://svn.apache.org/viewvc?rev=1098094&view=rev
Log:
Use alternate fast array access without blocking GC
Modified:
commons/sandbox/runtime/trunk/build.xml
commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/SystemIdTask.java
commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestExec.java
Modified: commons/sandbox/runtime/trunk/build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/build.xml?rev=1098094&r1=1098093&r2=1098094&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/build.xml (original)
+++ commons/sandbox/runtime/trunk/build.xml Sat Apr 30 10:27:03 2011
@@ -394,7 +394,7 @@ The Apache Software Foundation (http://w
<!-- Unit tests -->
<!-- =================================================================== -->
<target name="test" depends="tests">
- <runtest groups="init,core,private,${systemid.os}"/>
+ <runtest groups="init,core,private,${systemid.subsystem}"/>
</target>
<target name="testsemaphore" depends="tests">
Modified: commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/SystemIdTask.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/SystemIdTask.java?rev=1098094&r1=1098093&r2=1098094&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/SystemIdTask.java \
(original)
+++ commons/sandbox/runtime/trunk/src/build/org/apache/commons/runtime/ant/SystemIdTask.java \
Sat Apr 30 10:27:03 2011 @@ -73,6 +73,16 @@ public class SystemIdTask extends Task i
return platform;
}
+ /* Returns windows or posix
+ */
+ private static String getSubsystem()
+ {
+ if (getSysname().equals("windows"))
+ return "windows";
+ else
+ return "posix";
+ }
+
/* Copy of the {@code SystemId.getDataModel} method.
* Make sure those methods are in sync!
*/
@@ -201,6 +211,7 @@ public class SystemIdTask extends Task i
getProject().setNewProperty(prefix + ".data.model", getDataModel());
getProject().setNewProperty(prefix + ".OS", getSysname().toUpperCase());
getProject().setNewProperty(prefix + ".CPU", getProcessor().toUpperCase());
+ getProject().setNewProperty(prefix + ".subsystem", getSubsystem());
}
public boolean eval()
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c?rev=1098094&r1=1098093&r2=1098094&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c Sat Apr 30 10:27:03 \
2011 @@ -599,11 +599,12 @@ ACR_UNX_EXPORT(jlong, PosixExec, run0)(J
acr_buf_t *ib = 0;
acr_buf_t *ob = 0;
acr_buf_t *eb = 0;
-
+
WITH_CSTR(executable) {
WITH_CSTR(cwd) {
char **argp;
char **envs = 0;
+ jobject inpcopy = 0;
argp = AcrGetJavaStringArrayA(env, args);
if (argp == 0) {
@@ -619,10 +620,14 @@ ACR_UNX_EXPORT(jlong, PosixExec, run0)(J
goto cleanup;
}
}
- if (IS_JOBJECT_VALID(inp)) {
- ib = &bb[0];
- ib->len = (*env)->GetArrayLength(env, inp);
- ib->buf = (*env)->GetPrimitiveArrayCritical(env, inp, 0);
+ if (inp != 0) {
+ inpcopy = (*env)->NewLocalRef(env, inp);
+ if (inpcopy != 0) {
+ ib = &bb[0];
+ ib->len = (*env)->GetArrayLength(env, inpcopy);
+ ib->buf = (*env)->GetPrimitiveArrayCritical(env, inpcopy, 0);
+ (*env)->ReleasePrimitiveArrayCritical(env, inpcopy, ib->buf, 0);
+ }
}
if (IS_JOBJECT_VALID(out))
ob = &bb[1];
@@ -632,8 +637,8 @@ ACR_UNX_EXPORT(jlong, PosixExec, run0)(J
*/
rv = _run_exec(J2S(executable), argp, envs, J2S(cwd),
ob, eb, ib, timeout, &rc);
- if (ib != 0)
- (*env)->ReleasePrimitiveArrayCritical(env, inp, ib->buf, 0);
+ if (inpcopy != 0)
+ (*env)->DeleteLocalRef(env, inpcopy);
if (rv != ACR_PARENT_ERROR) {
if (ob != 0) {
/* Write to the output stream */
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c?rev=1098094&r1=1098093&r2=1098094&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/exec.c Sat Apr 30 10:27:03 \
2011 @@ -549,10 +549,15 @@ ACR_WIN_EXPORT(jlong, WindowsExec, run0)
WITH_WSTR(args) {
WITH_WSTR(cwd) {
WITH_WCHR(envb) {
- if (IS_JOBJECT_VALID(inp)) {
- ib = &bb[0];
- ib->len = (*env)->GetArrayLength(env, inp);
- ib->buf = (*env)->GetPrimitiveArrayCritical(env, inp, 0);
+ jobject inpcopy = 0;
+ if (inp != 0) {
+ inpcopy = (*env)->NewLocalRef(env, inp);
+ if (inpcopy != 0) {
+ ib = &bb[0];
+ ib->len = (*env)->GetArrayLength(env, inpcopy);
+ ib->buf = (*env)->GetPrimitiveArrayCritical(env, inpcopy, 0);
+ (*env)->ReleasePrimitiveArrayCritical(env, inpcopy, ib->buf, 0);
+ }
}
if (IS_JOBJECT_VALID(out))
ob = &bb[1];
@@ -562,8 +567,8 @@ ACR_WIN_EXPORT(jlong, WindowsExec, run0)
*/
rv = _run_exec(J2S(executable), J2S(args), J2S(envb), J2S(cwd),
ob, eb, ib, timeout, &rc);
- if (ib != 0)
- (*env)->ReleasePrimitiveArrayCritical(env, inp, ib->buf, 0);
+ if (inpcopy != 0)
+ (*env)->DeleteLocalRef(env, inpcopy);
if (rv != ACR_PARENT_ERROR) {
if (ob != 0) {
/* Write to the output stream */
@@ -584,10 +589,10 @@ ACR_WIN_EXPORT(jlong, WindowsExec, run0)
}
cleanup:
- if (ob != 0)
- AcrFree(ob->buf);
- if (eb != 0)
- AcrFree(eb->buf);
+ if (ob != 0)
+ AcrFree(ob->buf);
+ if (eb != 0)
+ AcrFree(eb->buf);
} DONE_WITH_STR(envb);
} DONE_WITH_STR(cwd);
} DONE_WITH_STR(args);
Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestExec.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestExec.java?rev=1098094&r1=1098093&r2=1098094&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestExec.java \
(original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestExec.java \
Sat Apr 30 10:27:03 2011 @@ -28,21 +28,33 @@ public class TestExec extends Assert
{
- @Test(groups = { "core" })
+ @Test(groups = { "posix" })
public void runPosix()
throws Exception
{
Exec e = Exec.newInstance();
assertNotNull(e);
ArrayList<String> args = new ArrayList<String>();
- if (Os.TYPE.contains(OsType.UNIX)) {
- args.add("/bin/ls");
- args.add("-al");
- }
- else {
- args.add("C:\\Windows\\System32\\cmd.exe");
- args.add("/V");
- }
+ args.add("/bin/ls");
+ args.add("-al");
+ e.redirectOutputStream(true);
+ e.redirectErrorStream(true);
+ int r = e.run(args);
+ assertEquals(r, Status.CHILD_DONE);
+ ByteArrayOutputStream os = (ByteArrayOutputStream)e.getOutputStream();
+ System.out.println("Exec returned:");
+ System.out.println(new String(os.toByteArray()));
+ }
+
+ @Test(groups = { "windows" })
+ public void runWindows()
+ throws Exception
+ {
+ Exec e = Exec.newInstance();
+ assertNotNull(e);
+ ArrayList<String> args = new ArrayList<String>();
+ args.add(ExecImpl.getInstance().getShell());
+ args.add("/V");
e.redirectOutputStream(true);
e.redirectErrorStream(true);
int r = e.run(args);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic