Author: mladen.turk(a)jboss.com
Date: 2007-09-28 10:03:06 -0400 (Fri, 28 Sep 2007)
New Revision: 1060
Modified:
trunk/sight/examples/org/jboss/sight/RunProcess.java
trunk/sight/native/share/no.c
Log:
Fix JBNATIVE-38
Modified: trunk/sight/examples/org/jboss/sight/RunProcess.java
===================================================================
--- trunk/sight/examples/org/jboss/sight/RunProcess.java 2007-09-28 13:02:51 UTC (rev
1059)
+++ trunk/sight/examples/org/jboss/sight/RunProcess.java 2007-09-28 14:03:06 UTC (rev
1060)
@@ -37,6 +37,39 @@
public class RunProcess {
+ private class ProcessWorker extends Thread
+ {
+
+ private Process proc;
+
+ public ProcessWorker(Process proc)
+ {
+ this.proc = proc;
+ }
+
+ public void run() {
+ try {
+ Thread.sleep(1000);
+ } catch (Exception e) {
+ // Skip
+ } finally {
+ try {
+ System.out.println("Destroying proc");
+ proc.destroy();
+ System.out.println("Destroyed proc");
+
+ } catch (Exception x) {
+ // Skip
+ x.printStackTrace();
+ }
+ }
+
+ }
+
+
+ }
+
+
private class Progress implements IProgressNotificationCallback
{
public Progress()
@@ -90,6 +123,8 @@
}
System.out.println();
System.out.println("Waiting for process to die ...");
+ ProcessWorker pw = new ProcessWorker(p);
+ pw.start();
Progress pc = new Progress();
int w = p.waitFor(pc, 3000);
System.out.println();
Modified: trunk/sight/native/share/no.c
===================================================================
--- trunk/sight/native/share/no.c 2007-09-28 13:02:51 UTC (rev 1059)
+++ trunk/sight/native/share/no.c 2007-09-28 14:03:06 UTC (rev 1060)
@@ -208,7 +208,7 @@
sight_object_t *no = J2P(instance, sight_object_t *);
jobject object = NULL;
apr_uint32_t ref_count;
-
+ int valid_global = 0;
UNREFERENCED_O;
#ifdef SIGHT_DO_STATS
@@ -216,6 +216,8 @@
#endif
if (!no)
return;
+ if (SIGHT_IS_VALID_GLOBAL())
+ valid_global = 1;
ref_count = apr_atomic_read32(&no->references);
while (ref_count) {
apr_thread_yield();
@@ -227,7 +229,7 @@
(*_E)->DeleteWeakGlobalRef(_E, no->object);
no->object = object;
}
- if (SIGHT_IS_VALID_GLOBAL()) {
+ if (valid_global) {
if (no->pool)
apr_pool_cleanup_kill(no->pool, no, native_object_cleanup);
if (no->object) {
Show replies by date