[Pkg-ocaml-maint-commits] [SCM] camljava packaging branch, master, updated. upstream/0.3.orig-8-gf477120

Stefano Zacchiroli zack at upsilon.cc
Thu Nov 26 17:08:11 UTC 2009


The following commit has been merged in the master branch:
commit f477120a96ab97c5e1b33529e707a4653b059d63
Author: Stefano Zacchiroli <zack at upsilon.cc>
Date:   Thu Nov 26 18:02:31 2009 +0100

    add thread safety patch from O'Jacare

diff --git a/debian/patches/0004-enforce-callback-invocation-from-main-thread.patch b/debian/patches/0004-enforce-callback-invocation-from-main-thread.patch
new file mode 100644
index 0000000..7db57d7
--- /dev/null
+++ b/debian/patches/0004-enforce-callback-invocation-from-main-thread.patch
@@ -0,0 +1,58 @@
+From: Gregoire Henry <Gregoire.Henry at pps.jussieu.fr>
+Date: Thu, 26 Nov 2009 18:00:50 +0100
+Subject: [PATCH] enforce callback invocation from main thread
+
+ensure that all callbacks are executed from the main thread
+(patch from O'Jacare)
+---
+ lib/jnistubs.c |   22 ++++++++++++++++++++++
+ 1 files changed, 22 insertions(+), 0 deletions(-)
+
+diff --git a/lib/jnistubs.c b/lib/jnistubs.c
+index 5d6b92e..e1659f8 100644
+--- a/lib/jnistubs.c
++++ b/lib/jnistubs.c
+@@ -14,6 +14,24 @@ static JNIEnv * jenv;
+ #define Val_jboolean(b) ((b) == JNI_FALSE ? Val_false : Val_true)
+ #define Jboolean_val(v) (Val_bool(v) ? JNI_TRUE : JNI_FALSE)
+ 
++/********** Threading *************/
++
++static JNIEnv * g_jenv;
++
++void init_threading() {
++  g_jenv = jenv;
++}
++
++void camljava_check_main_thread() {
++  if(jenv != g_jenv) {
++    fprintf(stderr, "CamlJava: callbacks from threads other than main are not allowed: ABORT.\n");
++    fflush(stderr);
++    // raise a Java exception would be better
++    exit(2);
++  }
++  return;
++}
++
+ /************ Wrapping of Java objects as Caml values *************/
+ 
+ #define JObject(v) (*((jobject *) Data_custom_val(v)))
+@@ -680,6 +698,7 @@ value camljava_Init(value vclasspath)
+   retcode = JNI_CreateJavaVM(&jvm, (void **) &jenv, &vm_args);
+   stat_free(classpath);
+   if (retcode < 0) failwith("Java.init");
++  init_threading(); // by O'Jacare
+   return Val_unit;
+ }
+ 
+@@ -781,6 +800,9 @@ static value camljava_callback(JNIEnv * env,
+ 
+   savedenv = jenv;
+   jenv = env;
++
++  camljava_check_main_thread(); // by O'Jacare
++
+   if (!caml_classes_initialized) {
+     if (init_caml_classes(env) == -1) return -1;
+     caml_classes_initialized = 1;
+-- 
diff --git a/debian/patches/series b/debian/patches/series
index 0e4c541..da265c6 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 0001-ldflags-for-recent-JDK.patch
 0002-Makefile-misc-fixes.patch
 0003-GC-global-reference-fix-for-JDK-1.6.patch
+0004-enforce-callback-invocation-from-main-thread.patch

-- 
camljava packaging



More information about the Pkg-ocaml-maint-commits mailing list