[PATCH] safe for when threading, related to gnome_show_url (was Re: request for help)




On 2001-08-21 11:27 Brian Stafford wrote:
> Can't help there, sorry.  Using uname() avoids the fork/exec and
> associated
> threading problems - I know there are pthreads functions designed to
> prevent
> potential deadlock when threaded processes fork but I forget what they
> are.

I attach a preleminary patch that should take care of the hang when
clicking on URLs. Please, give it a try if you have observe this
problem.

/Pawel
-- 
Pawel Salek (pawsa@theochem.kth.se) http://www.theochem.kth.se/~pawsa/
Theoretical Chemistry Division, KTH voice: +46 8 790-8202
Index: src/balsa-message.c
===================================================================
RCS file: /cvs/gnome/balsa/src/balsa-message.c,v
retrieving revision 1.174
diff -u -r1.174 balsa-message.c
--- src/balsa-message.c	2001/08/10 13:40:52	1.174
+++ src/balsa-message.c	2001/08/21 14:17:38
@@ -264,7 +264,33 @@
 
 }
 
+#ifdef BALSA_USE_THREADS
 static void
+lock_all(void)
+{
+    /* gdk lock is already held here: gdk_threads_enter() not needed */
+    /* lock all mailboxes here(?) */
+    libbalsa_lock_mutt();
+}
+static void
+unlock_all(void)
+{
+    libbalsa_unlock_mutt();
+    /* unlock all mailboxes here(?) */
+    gdk_threads_leave();
+}
+
+static void
+balsa_gnome_url_show(const gchar* url)
+{
+    pthread_atfork(lock_all, unlock_all, unlock_all);
+    gnome_url_show(url);
+}
+#else 
+#define balsa_gnome_url_show(s) gnome_url_show(s)
+#endif
+
+static void
 balsa_message_destroy(GtkObject * object)
 {
     BalsaMessage* bm = BALSA_MESSAGE(object);
@@ -1524,7 +1550,7 @@
 				 url->url);
 	gnome_appbar_set_status(balsa_app.appbar, notice);
 	g_free(notice);
-	gnome_url_show(url->url);
+	balsa_gnome_url_show(url->url);
 	break;
 //		    case URL_FTP: 
     case URL_MAILTO:
@@ -2264,7 +2290,7 @@
 static void
 balsa_gtk_html_link_clicked(GtkWidget *html, const gchar *url)
 {
-    gnome_url_show(url);
+    balsa_gnome_url_show(url);
 }
 #endif
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]