aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-01-23 07:16:33 +0800
committerDan Winship <danw@src.gnome.org>2001-01-23 07:16:33 +0800
commitff2d16601e0b4b71339b0820f4d2a5e0e92fdb92 (patch)
tree01655e9609b6c379a4f243dde2d55c036a230c1f /mail
parentc5cc88c6ca43bf5bd420b67b2212ab68f7203f47 (diff)
downloadgsoc2013-evolution-ff2d16601e0b4b71339b0820f4d2a5e0e92fdb92.tar.gz
gsoc2013-evolution-ff2d16601e0b4b71339b0820f4d2a5e0e92fdb92.tar.zst
gsoc2013-evolution-ff2d16601e0b4b71339b0820f4d2a5e0e92fdb92.zip
make mail_gui_thread non-static.
* mail-mt.[ch]: make mail_gui_thread non-static. * main.c (main): Set up signal handler for SEGV, BUS, FPE (segv_redirect): if a gnome-segv'ing signal is received in a thread other than mail_gui_thread, re-deliver it to that thread to work around a problem with the gnome segv handler. svn path=/trunk/; revision=7728
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog9
-rw-r--r--mail/mail-mt.c2
-rw-r--r--mail/mail-mt.h5
-rw-r--r--mail/main.c29
4 files changed, 41 insertions, 4 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 0f7f44d730..cd4510f31e 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,12 @@
+2001-01-22 Dan Winship <danw@ximian.com>
+
+ * mail-mt.[ch]: make mail_gui_thread non-static.
+
+ * main.c (main): Set up signal handler for SEGV, BUS, FPE
+ (segv_redirect): if a gnome-segv'ing signal is received in
+ a thread other than mail_gui_thread, re-deliver it to that
+ thread to work around a problem with the gnome segv handler.
+
2001-01-22 Jeffrey Stedfast <fejj@ximian.com>
* mail-format.c (handle_multipart_signed): Fixed to display
diff --git a/mail/mail-mt.c b/mail/mail-mt.c
index 1735432070..11cd181ce9 100644
--- a/mail/mail-mt.c
+++ b/mail/mail-mt.c
@@ -28,7 +28,7 @@ static GHashTable *mail_msg_active; /* table of active messages, must hold mail_
static pthread_mutex_t mail_msg_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t mail_msg_cond = PTHREAD_COND_INITIALIZER;
-static pthread_t mail_gui_thread; /* so we can tell when we're in the main thread, or not */
+pthread_t mail_gui_thread;
void *mail_msg_new(mail_msg_op_t *ops, EMsgPort *reply_port, size_t size)
{
diff --git a/mail/mail-mt.h b/mail/mail-mt.h
index de2f91d81b..8642a3ebaa 100644
--- a/mail/mail-mt.h
+++ b/mail/mail-mt.h
@@ -23,6 +23,7 @@
#ifndef _MAIL_MT
#define _MAIL_MT
+#include <pthread.h>
#include "camel/camel-exception.h"
#include "e-util/e-msgport.h"
#include "camel/camel-object.h"
@@ -78,4 +79,8 @@ extern EMsgPort *mail_gui_reply_port;
extern EThread *mail_thread_queued; /* for operations that can (or should) be queued */
extern EThread *mail_thread_new; /* for operations that should run in a new thread each time */
+/* The main thread. */
+extern pthread_t mail_gui_thread;
+
+
#endif /* ! _MAIL_MT */
diff --git a/mail/main.c b/mail/main.c
index ce0b776b08..2b3c08e452 100644
--- a/mail/main.c
+++ b/mail/main.c
@@ -40,10 +40,27 @@ static int blowup(int status)
}
#endif
+/* The GNOME SEGV handler will lose if it's not run from the main Gtk
+ * thread. So if we crash in another thread, redirect the signal.
+ */
+static void (*gnome_segv_handler) (int);
+
+static void
+segv_redirect (int sig)
+{
+ if (pthread_self () == mail_gui_thread)
+ gnome_segv_handler (sig);
+ else {
+ pthread_kill (mail_gui_thread, sig);
+ pthread_exit (NULL);
+ }
+}
+
int
main (int argc, char *argv [])
{
CORBA_ORB orb;
+ struct sigaction sa, osa;
#if 0
/* used to make elfence work */
@@ -61,6 +78,15 @@ main (int argc, char *argv [])
gnome_init_with_popt_table ("evolution-mail-component", VERSION,
argc, argv, oaf_popt_options, 0, NULL);
+
+ sa.sa_flags = 0;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_handler = segv_redirect;
+ sigaction (SIGSEGV, &sa, &osa);
+ sigaction (SIGBUS, &sa, NULL);
+ sigaction (SIGFPE, &sa, NULL);
+ gnome_segv_handler = osa.sa_handler;
+
orb = oaf_init (argc, argv);
if (bonobo_init (orb, CORBA_OBJECT_NIL,
@@ -87,9 +113,6 @@ main (int argc, char *argv [])
evolution_composer_factory_init (composer_send_cb,
composer_postpone_cb);
- signal (SIGSEGV, SIG_DFL);
- signal (SIGBUS, SIG_DFL);
-
if (gdk_threads_mutex) {
g_mutex_free (gdk_threads_mutex);
gdk_threads_mutex = NULL;