From aad4202594a706636bc893b8716a573861216175 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Mon, 29 Jan 2001 09:33:15 +0000 Subject: Debug function to compare the tree we think we have, after an incremental 2001-01-29 Not Zed * message-list.c (tree_equal): Debug function to compare the tree we think we have, after an incremental update. (build_tree): Check the tree after we've built it. * mail-mt.c (mail_get_password): If we are being called from the main gui thread, then just call the dialogue directly. Ideally we dont want this anyway but lets handle the case nicely. (mail_get_password): Try locking around the password request, to single-queue any password requests. (mail_msg_init): Push an exit handler to clean it up on completion. * mail-send-recv.c (receive_update_got_store): New function called when the store has been retrieved asynchronously. (mail_send_receive): Get the store asynchronously. This was causing problems where the password dialogue would try and be called from the main thread via a message. * mail-ops.c (mail_get_store): New function to get a store (a)synchronously. More or less taken from subscribe-dialog, which i will remove later. (mail_scan_subfolders): Try running the scan subfolder thing asynchronously, to help startup time. Not sure if this will work, but presumably the shell can handle the folders appearing later ok. svn path=/trunk/; revision=7886 --- mail/mail-mt.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'mail/mail-mt.c') diff --git a/mail/mail-mt.c b/mail/mail-mt.c index 11cd181ce9..103ddc0de6 100644 --- a/mail/mail-mt.c +++ b/mail/mail-mt.c @@ -216,6 +216,17 @@ mail_msg_received(EThread *e, EMsg *msg, void *data) m->ops->receive_msg(m); } +void mail_msg_cleanup(void) +{ + e_thread_destroy(mail_thread_queued); + e_thread_destroy(mail_thread_new); + + e_msgport_destroy(mail_gui_port); + e_msgport_destroy(mail_gui_reply_port); + + /* FIXME: channels too, etc */ +} + void mail_msg_init(void) { mail_gui_reply_port = e_msgport_new(); @@ -238,6 +249,8 @@ void mail_msg_init(void) mail_msg_active = g_hash_table_new(NULL, NULL); mail_gui_thread = pthread_self(); + + atexit(mail_msg_cleanup); } /* ********************************************************************** */ @@ -492,9 +505,19 @@ mail_get_password(char *prompt, gboolean secret) m->prompt = prompt; m->secret = secret; - e_msgport_put(mail_gui_port, (EMsg *)m); - e_msgport_wait(pass_reply); - r = (struct _pass_msg *)e_msgport_get(pass_reply); + if (pthread_self() == mail_gui_thread) { + do_get_pass((struct _mail_msg *)m); + r = m; + } else { + static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + + /* we want this single-threaded, this is the easiest way to do it without blocking ? */ + pthread_mutex_lock(&lock); + e_msgport_put(mail_gui_port, (EMsg *)m); + e_msgport_wait(pass_reply); + r = (struct _pass_msg *)e_msgport_get(pass_reply); + pthread_mutex_unlock(&lock); + } g_assert(r == m); -- cgit v1.2.3