evolution r36652 - trunk/mail



Author: abharath
Date: Sun Oct 19 17:08:50 2008
New Revision: 36652
URL: http://svn.gnome.org/viewvc/evolution?rev=36652&view=rev

Log:
2008-10-19  Milan Crha  <mcrha redhat com>

        ** Fix for bug #438155

         * message-list.h: (struct _MessageList): message-list.c: (message_list_init),
         (message_list_finalise), (regen_list_done), (regen_list_free), (ml_regen_timeout),
         (mail_regen_cancel): Guard access to the 'regen' list with a lock.


Modified:
   trunk/mail/ChangeLog
   trunk/mail/message-list.c
   trunk/mail/message-list.h

Modified: trunk/mail/message-list.c
==============================================================================
--- trunk/mail/message-list.c	(original)
+++ trunk/mail/message-list.c	Sun Oct 19 17:08:50 2008
@@ -2274,6 +2274,8 @@
 	message_list->cursor_uid = NULL;
 	message_list->last_sel_single = FALSE;
 
+	message_list->regen_lock = g_mutex_new ();
+
 	/* TODO: Should this only get the selection if we're realised? */
 	p = message_list->priv = g_malloc0(sizeof(*message_list->priv));
 	p->invisible = gtk_invisible_new();
@@ -2375,6 +2377,7 @@
 	g_free(message_list->cursor_uid);
 
 	g_mutex_free(message_list->hide_lock);
+	g_mutex_free (message_list->regen_lock);
 
 	g_free(message_list->folder_uri);
 	message_list->folder_uri = NULL;
@@ -4256,7 +4259,9 @@
 	m->ml->search = m->search;
 	m->search = NULL;
 
+	g_mutex_lock (m->ml->regen_lock);
 	m->ml->regen = g_list_remove(m->ml->regen, m);
+	g_mutex_unlock (m->ml->regen_lock);
 
 	if (m->ml->regen == NULL && m->ml->pending_select_uid) {
 		char *uid = m->ml->pending_select_uid;
@@ -4319,7 +4324,9 @@
 		camel_folder_change_info_free (m->changes);
 
 	/* we have to poke this here as well since we might've been cancelled and regened wont get called */
+	g_mutex_lock (m->ml->regen_lock);
 	m->ml->regen = g_list_remove(m->ml->regen, m);
+	g_mutex_unlock (m->ml->regen_lock);
 
 	if (m->expand_state)
 		xmlFreeDoc (m->expand_state);
@@ -4340,7 +4347,9 @@
 {
 	e_profile_event_emit("list.regenerate", m->folder->full_name, 0);
 
+	g_mutex_lock (m->ml->regen_lock);
 	m->ml->regen = g_list_prepend(m->ml->regen, m);
+	g_mutex_unlock (m->ml->regen_lock);
 	/* TODO: we should manage our own thread stuff, would make cancelling outstanding stuff easier */
 	mail_msg_fast_ordered_push (m);
 
@@ -4355,8 +4364,11 @@
 {
 	/* cancel any outstanding regeneration requests, not we don't clear, they clear themselves */
 	if (ml->regen) {
-		GList *l = ml->regen;
+		GList *l;
+
+		g_mutex_lock (ml->regen_lock);
 
+		l = ml->regen;
 		while (l) {
 			MailMsg *mm = l->data;
 
@@ -4364,6 +4376,8 @@
 				camel_operation_cancel(mm->cancel);
 			l = l->next;
 		}
+
+		g_mutex_unlock (ml->regen_lock);
 	}
 
 	/* including unqueued ones */

Modified: trunk/mail/message-list.h
==============================================================================
--- trunk/mail/message-list.h	(original)
+++ trunk/mail/message-list.h	Sun Oct 19 17:08:50 2008
@@ -151,6 +151,7 @@
 
 	/* list of outstanding regeneration requests */
 	GList *regen;
+	GMutex *regen_lock; /* when writing to the regen, guard with this lock too */
 	char *pending_select_uid; /* set if we were busy regnerating while we had a select come in */
 	guint regen_timeout_id;
 	void *regen_timeout_msg;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]