evolution-data-server r9314 - trunk/camel



Author: psankar
Date: Mon Aug 11 06:45:47 2008
New Revision: 9314
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9314&view=rev

Log:
2008-08-11  Sankar P  <psankar novell com>

	* camel-folder-summary.c (summary_remove_uid),
	(camel_folder_summary_remove), (camel_folder_summary_remove_uid):
	Do not attempt to delete non-existing uids from the db.
	Save some disk access and associated disk-head travel costs. 




Modified:
   trunk/camel/ChangeLog
   trunk/camel/camel-folder-summary.c

Modified: trunk/camel/camel-folder-summary.c
==============================================================================
--- trunk/camel/camel-folder-summary.c	(original)
+++ trunk/camel/camel-folder-summary.c	Mon Aug 11 06:45:47 2008
@@ -2014,7 +2014,10 @@
 	camel_db_clear_folder_summary (cdb, folder_name, NULL);	
 }
 
-static void
+
+/* This function returns 0 on success. So the caller should not bother,
+deleting the uid from db when the return value is non-zero */
+static int 
 summary_remove_uid (CamelFolderSummary *s, const char *uid)
 {
 	int i;
@@ -2027,12 +2030,12 @@
 			/* FIXME: Does using fast remove affect anything ? */
 			g_ptr_array_remove_index(s->uids, i);
 			camel_pstring_free (uid);
-			break;
+			return 0;
 		}
 
 	}
 
-	return ;
+	return -1;
 }
 
 /**
@@ -2045,17 +2048,20 @@
 void
 camel_folder_summary_remove (CamelFolderSummary *s, CamelMessageInfo *info)
 {
+
+	int ret;
+
 	CAMEL_SUMMARY_LOCK(s, summary_lock);
 
 	g_hash_table_remove (s->loaded_infos, camel_message_info_uid(info));	
-	summary_remove_uid (s, camel_message_info_uid(info));
+	ret = summary_remove_uid (s, camel_message_info_uid(info));
 
 	
 	s->flags |= CAMEL_SUMMARY_DIRTY;
 	s->meta_summary->msg_expunged = TRUE;
 	CAMEL_SUMMARY_UNLOCK(s, summary_lock);
 	
-	if (camel_db_delete_uid (s->folder->cdb, s->folder->full_name, camel_message_info_uid(info), NULL) != 0)
+	if (!ret && camel_db_delete_uid (s->folder->cdb, s->folder->full_name, camel_message_info_uid(info), NULL) != 0)
 		return ;
 	
 	camel_message_info_free(info);
@@ -2072,31 +2078,32 @@
 void
 camel_folder_summary_remove_uid(CamelFolderSummary *s, const char *uid)
 {
-        CamelMessageInfo *oldinfo;
-        char *olduid;
-
-	CAMEL_SUMMARY_LOCK(s, summary_lock);
-	CAMEL_SUMMARY_LOCK(s, ref_lock);
-        if (g_hash_table_lookup_extended(s->loaded_infos, uid, (void *)&olduid, (void *)&oldinfo)) {
-		/* make sure it doesn't vanish while we're removing it */
-		oldinfo->refcount++;
-		CAMEL_SUMMARY_UNLOCK(s, ref_lock);
-		CAMEL_SUMMARY_UNLOCK(s, summary_lock);
-		camel_folder_summary_remove(s, oldinfo);
-		camel_message_info_free(oldinfo);
-	} else {
-		char *tmpid = g_strdup (uid);
-		/* Info isn't loaded into the memory. We must just remove the UID*/
-		summary_remove_uid (s, uid);
-		CAMEL_SUMMARY_UNLOCK(s, ref_lock);
-		CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+		CamelMessageInfo *oldinfo;
+		char *olduid;
 
-		if (camel_db_delete_uid (s->folder->cdb, s->folder->full_name, tmpid, NULL) != 0) {
-			g_free(tmpid);
-			return ;
+		CAMEL_SUMMARY_LOCK(s, summary_lock);
+		CAMEL_SUMMARY_LOCK(s, ref_lock);
+		if (g_hash_table_lookup_extended(s->loaded_infos, uid, (void *)&olduid, (void *)&oldinfo)) {
+				/* make sure it doesn't vanish while we're removing it */
+				oldinfo->refcount++;
+				CAMEL_SUMMARY_UNLOCK(s, ref_lock);
+				CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+				camel_folder_summary_remove(s, oldinfo);
+				camel_message_info_free(oldinfo);
+		} else {
+				char *tmpid = g_strdup (uid);
+				int ret;
+				/* Info isn't loaded into the memory. We must just remove the UID*/
+				ret = summary_remove_uid (s, uid);
+				CAMEL_SUMMARY_UNLOCK(s, ref_lock);
+				CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+
+				if (!ret && camel_db_delete_uid (s->folder->cdb, s->folder->full_name, tmpid, NULL) != 0) {
+						g_free(tmpid);
+						return ;
+				}
+				g_free (tmpid);
 		}
-		g_free (tmpid);
-	}
 }
 
 void



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