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
This commit is contained in:
Dan Winship
2001-01-22 23:16:33 +00:00
parent c5cc88c6ca
commit ff2d16601e
4 changed files with 41 additions and 4 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -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 */

View File

@ -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;