aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-mt.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2001-01-29 17:33:15 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-01-29 17:33:15 +0800
commitaad4202594a706636bc893b8716a573861216175 (patch)
treef0e1c0efaf1b86a1408805353f3e914216aa469a /mail/mail-mt.c
parent1b18f022ca57ebebb272a148b25173d92b2b89c5 (diff)
downloadgsoc2013-evolution-aad4202594a706636bc893b8716a573861216175.tar
gsoc2013-evolution-aad4202594a706636bc893b8716a573861216175.tar.gz
gsoc2013-evolution-aad4202594a706636bc893b8716a573861216175.tar.bz2
gsoc2013-evolution-aad4202594a706636bc893b8716a573861216175.tar.lz
gsoc2013-evolution-aad4202594a706636bc893b8716a573861216175.tar.xz
gsoc2013-evolution-aad4202594a706636bc893b8716a573861216175.tar.zst
gsoc2013-evolution-aad4202594a706636bc893b8716a573861216175.zip
Debug function to compare the tree we think we have, after an incremental
2001-01-29 Not Zed <NotZed@Ximian.com> * 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
Diffstat (limited to 'mail/mail-mt.c')
-rw-r--r--mail/mail-mt.c29
1 files changed, 26 insertions, 3 deletions
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);