diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-06-24 23:12:53 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-06-24 23:13:38 +0800 |
commit | 4c36dfa3251be50c00dee30dcb1905fadb62b783 (patch) | |
tree | aa541527538a51d498a54677492720cae6aee8ea | |
parent | f219d4b1b2feb737a8fe28ceadcb4c01f4b215fc (diff) | |
download | gsoc2013-evolution-4c36dfa3251be50c00dee30dcb1905fadb62b783.tar.gz gsoc2013-evolution-4c36dfa3251be50c00dee30dcb1905fadb62b783.tar.zst gsoc2013-evolution-4c36dfa3251be50c00dee30dcb1905fadb62b783.zip |
Bug 622547 - mail_async_event_destroy() doesn't cancel its idle callback
-rw-r--r-- | mail/mail-mt.c | 19 | ||||
-rw-r--r-- | mail/mail-mt.h | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/mail/mail-mt.c b/mail/mail-mt.c index 5f656c9ec9..fbc0faeb00 100644 --- a/mail/mail-mt.c +++ b/mail/mail-mt.c @@ -608,6 +608,7 @@ struct _proxy_msg { mail_async_event_t type; GThread *thread; + guint idle_id; MailAsyncFunc func; gpointer o; @@ -628,10 +629,11 @@ do_async_event(struct _proxy_msg *m) } static gint -idle_async_event(gpointer mm) +idle_async_event (struct _proxy_msg *m) { - do_async_event(mm); - mail_msg_unref(mm); + m->idle_id = 0; + do_async_event (m); + mail_msg_unref (m); return FALSE; } @@ -655,7 +657,7 @@ mail_async_event_new (void) return ea; } -gint +guint mail_async_event_emit (MailAsyncEvent *ea, mail_async_event_t type, MailAsyncFunc func, @@ -664,7 +666,7 @@ mail_async_event_emit (MailAsyncEvent *ea, gpointer data) { struct _proxy_msg *m; - gint id; + guint id; /* We dont have a reply port for this, we dont * care when/if it gets executed, just queue it. */ @@ -687,7 +689,8 @@ mail_async_event_emit (MailAsyncEvent *ea, * overflow and deadlock us. */ if (type == MAIL_ASYNC_GUI) { if (mail_in_main_thread ()) - g_idle_add(idle_async_event, m); + m->idle_id = g_idle_add ( + (GSourceFunc) idle_async_event, m); else mail_msg_main_loop_push(m); } else @@ -712,6 +715,10 @@ mail_async_event_destroy (MailAsyncEvent *ea) errno = EDEADLK; return -1; } + if (m->idle_id > 0) { + g_source_remove (m->idle_id); + m->idle_id = 0; + } g_mutex_unlock(ea->lock); mail_msg_wait(id); g_mutex_lock(ea->lock); diff --git a/mail/mail-mt.h b/mail/mail-mt.h index 2e8828c5b2..cf59081e0f 100644 --- a/mail/mail-mt.h +++ b/mail/mail-mt.h @@ -102,7 +102,7 @@ typedef void (*MailAsyncFunc)(gpointer , gpointer , gpointer ); /* create a new async event handler */ MailAsyncEvent *mail_async_event_new(void); /* forward a camel event (or other call) to the gui thread */ -gint mail_async_event_emit(MailAsyncEvent *ea, mail_async_event_t type, MailAsyncFunc func, gpointer , gpointer , gpointer ); +guint mail_async_event_emit(MailAsyncEvent *ea, mail_async_event_t type, MailAsyncFunc func, gpointer , gpointer , gpointer ); /* wait for all outstanding async events to complete */ gint mail_async_event_destroy(MailAsyncEvent *ea); |