[evolution-patches] patch for addressbook 60889



So this bug is kinda gross, but the easiest solution to this problem is
to limit in the front end the number of simultaneous requests that we
make.  Long term the solution will have to be a POA arg that allows us
to set the thread pool max size.

I was supposed to report before/after timings based on this patch, but I
could only get "after" timings, as before this patch evo crashed every
time I tried to add more than 10 contacts at a time.
 
Chris
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1817
diff -u -p -r1.1817 ChangeLog
--- ChangeLog	25 Aug 2004 10:56:21 -0000	1.1817
+++ ChangeLog	25 Aug 2004 14:26:16 -0000
@@ -1,3 +1,19 @@
+2004-08-25  Chris Toshok  <toshok ximian com>
+
+	[ patch for the rest of 60889 ]
+	* gui/merging/eab-contact-merging.c (add_lookup): new function,
+	either start up the query or add it to the queue if we're over the
+	number of simultaneous queries.
+	(finished_lookup): start up enough pending queries to get us to
+	our limit again.
+	(free_lookup): free lookup->avoid.
+	(final_id_cb): call finished_lookup.
+	(eab_merging_book_add_contact): set lookup->avoid to NULL and
+	replace call to eab_contact_locate_match_full with add_lookup.
+	(eab_merging_book_commit_contact): set lookup->avoid to the
+	contact, and make the same
+	s/eab_contact_locate_match_full/add_lookup/ replacement.
+
 2004-08-25  Frederic Crozat  <fcrozat mandrakesoft com>
 
 	* gui/component/addressbook-view.c: (delete_addressbook_cb):
Index: gui/merging/eab-contact-merging.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/merging/eab-contact-merging.c,v
retrieving revision 1.3
diff -u -p -r1.3 eab-contact-merging.c
--- gui/merging/eab-contact-merging.c	6 Apr 2004 00:31:08 -0000	1.3
+++ gui/merging/eab-contact-merging.c	25 Aug 2004 14:26:16 -0000
@@ -26,16 +26,58 @@ typedef struct {
 	EContactMergingOpType op;
 	EBook *book;
 	EContact *contact;
+	GList *avoid;
 	EBookIdCallback id_cb;
 	EBookCallback   cb;
 	gpointer closure;
 } EContactMergingLookup;
 
+static void match_query_callback (EContact *contact, EContact *match, EABContactMatchType type, gpointer closure);
+
+#define SIMULTANEOUS_MERGING_REQUESTS 20
+
+static GList *merging_queue = NULL;
+static int running_merge_requests = 0;
+
+
+static void
+add_lookup (EContactMergingLookup *lookup)
+{
+	if (running_merge_requests < SIMULTANEOUS_MERGING_REQUESTS) {
+		running_merge_requests++;
+		eab_contact_locate_match_full (lookup->book, lookup->contact, lookup->avoid, match_query_callback, lookup);
+	}
+	else {
+		merging_queue = g_list_append (merging_queue, lookup);
+	}
+}
+
+static void
+finished_lookup (void)
+{
+	running_merge_requests--;
+
+	while (running_merge_requests < SIMULTANEOUS_MERGING_REQUESTS) {
+		EContactMergingLookup *lookup;
+		
+		if (!merging_queue)
+			break;
+
+		lookup = merging_queue->data;
+
+		merging_queue = g_list_remove_link (merging_queue, merging_queue);
+
+		running_merge_requests++;
+		eab_contact_locate_match_full (lookup->book, lookup->contact, lookup->avoid, match_query_callback, lookup);
+	}
+}
+
 static void
 free_lookup (EContactMergingLookup *lookup)
 {
 	g_object_unref (lookup->book);
 	g_object_unref (lookup->contact);
+	g_list_free (lookup->avoid);
 
 	g_free (lookup);
 }
@@ -49,6 +91,8 @@ final_id_cb (EBook *book, EBookStatus st
 		lookup->id_cb (lookup->book, status, id, lookup->closure);
 
 	free_lookup (lookup);
+
+	finished_lookup ();
 }
 
 static void
@@ -60,6 +104,8 @@ final_cb (EBook *book, EBookStatus statu
 		lookup->cb (lookup->book, status, lookup->closure);
 
 	free_lookup (lookup);
+
+	finished_lookup ();
 }
 
 static void
@@ -151,8 +197,9 @@ eab_merging_book_add_contact (EBook     
 	lookup->contact = g_object_ref (contact);
 	lookup->id_cb = cb;
 	lookup->closure = closure;
+	lookup->avoid = NULL;
 
-	eab_contact_locate_match_full (book, contact, NULL, match_query_callback, lookup);
+	add_lookup (lookup);
 
 	return TRUE;
 }
@@ -164,7 +211,6 @@ eab_merging_book_commit_contact (EBook  
 				 gpointer               closure)
 {
 	EContactMergingLookup *lookup;
-	GList *avoid;
 	
 	lookup = g_new (EContactMergingLookup, 1);
 
@@ -173,12 +219,9 @@ eab_merging_book_commit_contact (EBook  
 	lookup->contact = g_object_ref (contact);
 	lookup->cb = cb;
 	lookup->closure = closure;
+	lookup->avoid = g_list_append (NULL, contact);
 
-	avoid = g_list_append (NULL, contact);
-
-	eab_contact_locate_match_full (book, contact, avoid, match_query_callback, lookup);
-
-	g_list_free (avoid);
+	add_lookup (lookup);
 
 	return TRUE;
 }


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