Delivered-To: garrigue at math.nagoya-u.ac.jp Delivered-To: lablgtk at yquem.inria.fr Date: Tue, 22 Jun 2010 18:53:38 +0100 To: lablgtk at yquem.inria.fr Subject: [PATCH] Re: [Lablgtk] dialog#run seems to block other threads Message-ID: <20100622175338.GB6495 at annexia.org> References: <20100622170649.GA6495 at annexia.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="QTprm0S8XgL7H0Dt" Content-Disposition: inline In-Reply-To: <20100622170649.GA6495 at annexia.org> From: Richard Jones Status: RO --QTprm0S8XgL7H0Dt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I looked at the lablgtk2 source and I can see the problem. The wrapper for dialog#run doesn't even attempt to release the OCaml GC lock. I have applied the following patch to my local copy, which appears to cure the problem for me. I don't know if it is safe to release the lock at this point, perhaps someone who knows the code a bit better could comment. Unless I'm doing it wrong, I don't see any calls to caml_enter_blocking_section in the whole of the lablgtk2 code base ... Rich. --=20 Richard Jones Red Hat --QTprm0S8XgL7H0Dt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="lablgtk2-2.14.0-dialog-run-non-blocking.patch" Content-Transfer-Encoding: quoted-printable --- lablgtk-2.14.0.orig/src/ml_gtk.c 2009-08-29 17:28:12.000000000 -0400 +++ lablgtk-2.14.0/src/ml_gtk.c 2010-06-22 13:35:53.566433805 -0400 @@ -29,6 +29,7 @@ #include #include #include +#include =20 #include "wrappers.h" #include "ml_glib.h" @@ -676,7 +677,24 @@ ML_3 (gtk_dialog_add_button, GtkDialog_val, String_val, Int_val, Unit) ML_3 (gtk_dialog_set_response_sensitive, GtkDialog_val, Int_val, Bool_val,= Unit) ML_2 (gtk_dialog_set_default_response, GtkDialog_val, Int_val, Unit) -ML_1 (gtk_dialog_run, GtkDialog_val, Val_int) + +CAMLprim value +ml_gtk_dialog_run (value dialogv) +{ + CAMLparam1 (dialogv); + GtkDialog *d =3D GtkDialog_val (dialogv); + int r; + + /* Allow other OCaml threads to run while the dialog is being + * displayed. - RWMJ. + */ + caml_enter_blocking_section (); + r =3D gtk_dialog_run (d); + caml_leave_blocking_section (); + + CAMLreturn (Val_int (r)); +} + /* gtk_dialog_add_action_widget */ =20 /* gtkinputdialog.h */ --QTprm0S8XgL7H0Dt Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk --QTprm0S8XgL7H0Dt--