[evolution-patches] probably fix for addressbook bug 61052



the pending_idles GList is accessed by potentially multiple threads, and
wasn't protected with a mutex.  Now it is..  I couldn't ever reproduce
this bug, but the change hasn't had a negative impact on me since I
applied it.

Chris
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/ChangeLog,v
retrieving revision 1.176
diff -u -r1.176 ChangeLog
--- ChangeLog	13 Jul 2004 19:56:43 -0000	1.176
+++ ChangeLog	14 Jul 2004 22:42:03 -0000
@@ -1,3 +1,30 @@
+2004-07-14  Chris Toshok  <toshok ximian com>
+
+	[ fixes #61052 ]
+	
+	* libebook/e-book.c (e_book_op_remove): lock the book's mutex
+	around operations on the id_to_op hashtable, as is done in all
+	other e_book_* functions.
+	(emit_async_add_contact_response): lock the book's mutex around
+	operations on the pending_idle list.
+	(e_book_response_add_contact): same.
+	(emit_async_elist_response): same.
+	(e_book_response_get_supported_fields): same.
+	(e_book_response_get_supported_auth_methods): same.
+	(emit_async_get_contact_response): same.
+	(e_book_response_get_contact): same.
+	(emit_async_get_book_view_response): same.
+	(e_book_response_get_book_view): same.
+	(emit_async_get_contacts_response): same.
+	(e_book_response_get_contacts): same.
+	(emit_async_get_changes_response): same.
+	(e_book_response_get_changes): same.
+	(emit_async_generic_response): same.
+	(e_book_response_generic): same.
+	(emit_async_open_response): same.
+	(e_book_response_open): same.
+	(e_book_response_remove): same.
+
 2004-07-13  Chris Toshok  <toshok ximian com>
 
 	* libebook/e-book.c (e_book_get_self): only propagate the GError
Index: libebook/e-book.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-book.c,v
retrieving revision 1.36
diff -u -r1.36 e-book.c
--- libebook/e-book.c	13 Jul 2004 19:56:43 -0000	1.36
+++ libebook/e-book.c	14 Jul 2004 22:42:04 -0000
@@ -191,8 +191,10 @@
 e_book_op_remove (EBook *book,
 		  EBookOp *op)
 {
+	g_mutex_lock (book->priv->mutex);
 	g_hash_table_remove (book->priv->id_to_op,
 			     &op->opid);
+	g_mutex_unlock (book->priv->mutex);
 }
 
 static void
@@ -357,8 +359,10 @@
 
 	g_free (op->id);
 
+	g_mutex_lock (book->priv->mutex);
 	book->priv->pending_idles = g_list_remove (book->priv->pending_idles,
 						   GINT_TO_POINTER (op->idle_id));
+	g_mutex_unlock (book->priv->mutex);
 
 	e_book_clear_op (book, op);
 
@@ -399,8 +403,10 @@
 		op->book = g_object_ref (book);
 
 		op->idle_id = g_idle_add (emit_async_add_contact_response, op);
+		g_mutex_lock (book->priv->mutex);
 		book->priv->pending_idles = g_list_prepend (book->priv->pending_idles,
 							    GINT_TO_POINTER (op->idle_id));
+		g_mutex_unlock (book->priv->mutex);
 	}
 }
 
@@ -674,8 +680,10 @@
 
 	g_object_unref (op->elist);
 
+	g_mutex_lock (book->priv->mutex);
 	book->priv->pending_idles = g_list_remove (book->priv->pending_idles,
 						   GINT_TO_POINTER (op->idle_id));
+	g_mutex_unlock (book->priv->mutex);
 
 	e_book_clear_op (book, op);
 
@@ -724,8 +732,10 @@
 		op->elist = efields;
 
 		op->idle_id = g_idle_add (emit_async_elist_response, op);
+		g_mutex_lock (book->priv->mutex);
 		book->priv->pending_idles = g_list_prepend (book->priv->pending_idles,
 							    GINT_TO_POINTER (op->idle_id));
+		g_mutex_unlock (book->priv->mutex);
 	}
 }
 
@@ -892,8 +902,10 @@
 		op->elist = emethods;
 
 		op->idle_id = g_idle_add (emit_async_elist_response, op);
+		g_mutex_lock (book->priv->mutex);
 		book->priv->pending_idles = g_list_prepend (book->priv->pending_idles,
 							    GINT_TO_POINTER (op->idle_id));
+		g_mutex_unlock (book->priv->mutex);
 	}
 }
 
@@ -1182,8 +1194,10 @@
 
 	g_object_unref (op->contact);
 
+	g_mutex_lock (book->priv->mutex);
 	book->priv->pending_idles = g_list_remove (book->priv->pending_idles,
 						   GINT_TO_POINTER (op->idle_id));
+	g_mutex_unlock (book->priv->mutex);
 
 	e_book_clear_op (book, op);
 
@@ -1223,8 +1237,10 @@
 		op->book = g_object_ref (book);
 
 		op->idle_id = g_idle_add (emit_async_get_contact_response, op);
+		g_mutex_lock (book->priv->mutex);
 		book->priv->pending_idles = g_list_prepend (book->priv->pending_idles,
 							    GINT_TO_POINTER (op->idle_id));
+		g_mutex_unlock (book->priv->mutex);
 	}
 }
 
@@ -1604,8 +1620,10 @@
 
 	g_object_unref (op->view);
 
+	g_mutex_lock (book->priv->mutex);
 	book->priv->pending_idles = g_list_remove (book->priv->pending_idles,
 						   GINT_TO_POINTER (op->idle_id));
+	g_mutex_unlock (book->priv->mutex);
 
 	e_book_clear_op (book, op);
 
@@ -1648,8 +1666,10 @@
 		op->book = g_object_ref (book);
 
 		op->idle_id = g_idle_add (emit_async_get_book_view_response, op);
+		g_mutex_lock (book->priv->mutex);
 		book->priv->pending_idles = g_list_prepend (book->priv->pending_idles,
 							    GINT_TO_POINTER (op->idle_id));
+		g_mutex_unlock (book->priv->mutex);
 	}
 }
 
@@ -1800,8 +1820,11 @@
 	g_list_foreach (op->list, (GFunc)g_object_unref, NULL);
 	g_list_free (op->list);
 
+	g_mutex_lock (book->priv->mutex);
 	book->priv->pending_idles = g_list_remove (book->priv->pending_idles,
 						   GINT_TO_POINTER (op->idle_id));
+	g_mutex_unlock (book->priv->mutex);
+
 	e_book_clear_op (book, op);
 
 	g_object_unref (book);
@@ -1842,8 +1865,10 @@
 		op->book = g_object_ref (book);
 		op->status = status;
 		op->idle_id = g_idle_add (emit_async_get_contacts_response, op);
+		g_mutex_lock (book->priv->mutex);
 		book->priv->pending_idles = g_list_prepend (book->priv->pending_idles,
 							    GINT_TO_POINTER (op->idle_id));
+		g_mutex_unlock (book->priv->mutex);
 	}
 }
 
@@ -1975,8 +2000,11 @@
 		op->cb.list (book, op->status, op->list, op->closure);
 	e_book_free_change_list (op->list);
 
+	g_mutex_lock (book->priv->mutex);
 	book->priv->pending_idles = g_list_remove (book->priv->pending_idles,
 						   GINT_TO_POINTER (op->idle_id));
+	g_mutex_unlock (book->priv->mutex);
+
 	e_book_clear_op (book, op);
 
 	g_object_unref (book);
@@ -2013,8 +2041,10 @@
 	else {
 		op->book = g_object_ref (book);
 		op->idle_id = g_idle_add (emit_async_get_changes_response, op);
+		g_mutex_lock (book->priv->mutex);
 		book->priv->pending_idles = g_list_prepend (book->priv->pending_idles,
 							    GINT_TO_POINTER (op->idle_id));
+		g_mutex_unlock (book->priv->mutex);
 	}
 }
 
@@ -2043,8 +2073,11 @@
 	if (op->cb.status)
 		op->cb.status (book, op->status, op->closure);
 
+	g_mutex_lock (book->priv->mutex);
 	book->priv->pending_idles = g_list_remove (book->priv->pending_idles,
 						   GINT_TO_POINTER (op->idle_id));
+	g_mutex_unlock (book->priv->mutex);
+
 	e_book_clear_op (book, op);
 
 	g_object_unref (book);
@@ -2079,8 +2112,10 @@
 		op->book = g_object_ref (book);
 		op->status = status;
 		op->idle_id = g_idle_add (emit_async_generic_response, op);
+		g_mutex_lock (book->priv->mutex);
 		book->priv->pending_idles = g_list_prepend (book->priv->pending_idles,
 							    GINT_TO_POINTER (op->idle_id));
+		g_mutex_unlock (book->priv->mutex);
 	}
 }
 
@@ -2314,8 +2349,11 @@
 	if (op->cb.status)
 		op->cb.status (book, op->status, op->closure);
 
+	g_mutex_lock (book->priv->mutex);
 	book->priv->pending_idles = g_list_remove (book->priv->pending_idles,
 						   GINT_TO_POINTER (op->idle_id));
+	g_mutex_unlock (book->priv->mutex);
+
 	e_book_clear_op (book, op);
 
 	g_object_unref (book);
@@ -2352,8 +2390,10 @@
 		op->book = g_object_ref (book);
 		op->status = status;
 		op->idle_id = g_idle_add (emit_async_open_response, op);
+		g_mutex_lock (book->priv->mutex);
 		book->priv->pending_idles = g_list_prepend (book->priv->pending_idles,
 							    GINT_TO_POINTER (op->idle_id));
+		g_mutex_unlock (book->priv->mutex);
 	}
 }
 
@@ -2493,8 +2533,10 @@
 		op->book = g_object_ref (book);
 		op->status = status;
 		op->idle_id = g_idle_add (emit_async_generic_response, op);
+		g_mutex_lock (book->priv->mutex);
 		book->priv->pending_idles = g_list_prepend (book->priv->pending_idles,
 							    GINT_TO_POINTER (op->idle_id));
+		g_mutex_unlock (book->priv->mutex);
 	}
 }
 


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