Re: Patch: use internal folder summary cache always
- From: Jose Dapena Paz <jdapena igalia com>
- To: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: Re: Patch: use internal folder summary cache always
- Date: Fri, 21 Dec 2007 19:53:33 +0100
El vie, 21-12-2007 a las 10:46 +0100, Jose Dapena Paz escribió:
> This patch also includes some changes to make save_append operation
> work a bit better. Unfortunately, this is not enough as I'm getting
> heavy corruption (mainly with move to operation in pop folders). Then,
> it still needs more work, and that's why append is disabled now.
This new patch converts the hash lock into a recursive lock, and then,
I avoid the silly while hack.
--
Jose Dapena Paz <jdapena igalia com>
Igalia
Index: libtinymail-camel/camel-lite/camel/camel-folder-summary.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-folder-summary.c (revision 3176)
+++ libtinymail-camel/camel-lite/camel/camel-folder-summary.c (working copy)
@@ -171,30 +171,18 @@
find_message_info_with_uid (CamelFolderSummary *s, const char *uid)
{
CamelMessageInfo *retval = NULL;
- guint i = 0;
if (uid == NULL || strlen (uid) <= 0)
return NULL;
- g_mutex_lock (s->hash_lock);
- if (s->uidhash != NULL)
+ g_static_rec_mutex_lock (s->hash_lock);
+ camel_folder_summary_prepare_hash (s);
+
+ if (s->uidhash != NULL) {
retval = g_hash_table_lookup (s->uidhash, uid);
- g_mutex_unlock (s->hash_lock);
+ }
+ g_static_rec_mutex_unlock (s->hash_lock);
- if (retval == NULL)
- for (i=0; G_LIKELY (i < s->messages->len) ; i++)
- {
- CamelMessageInfo *info = s->messages->pdata[i];
-
- /* This can cause cache trashing */
- if (G_UNLIKELY (info->uid[0] == uid[0]) &&
- G_UNLIKELY (!strcmp (info->uid, uid)))
- {
- retval = info;
- break;
- }
- }
-
return retval;
}
@@ -251,7 +239,8 @@
s->messages = g_ptr_array_new();
s->expunged = g_ptr_array_new();
s->uidhash = NULL;
- s->hash_lock = g_mutex_new ();
+ s->hash_lock = g_new0 (GStaticRecMutex, 1);
+ g_static_rec_mutex_init (s->hash_lock);
p->summary_lock = g_mutex_new();
p->io_lock = g_mutex_new();
@@ -264,7 +253,7 @@
{
guint i = 0;
- g_mutex_lock (s->hash_lock);
+ g_static_rec_mutex_lock (s->hash_lock);
if (s->uidhash == NULL)
{
@@ -278,18 +267,18 @@
}
}
- g_mutex_unlock (s->hash_lock);
+ g_static_rec_mutex_unlock (s->hash_lock);
}
void
camel_folder_summary_kill_hash (CamelFolderSummary *s)
{
- g_mutex_lock (s->hash_lock);
+ g_static_rec_mutex_lock (s->hash_lock);
if (s->uidhash != NULL)
g_hash_table_destroy (s->uidhash);
s->uidhash = NULL;
- g_mutex_unlock (s->hash_lock);
+ g_static_rec_mutex_unlock (s->hash_lock);
}
@@ -371,7 +360,7 @@
if (s->uidhash != NULL)
g_hash_table_destroy (s->uidhash);
- g_mutex_free(s->hash_lock);
+ g_static_rec_mutex_free(s->hash_lock);
g_mutex_free(p->summary_lock);
g_mutex_free(p->io_lock);
@@ -1151,10 +1140,10 @@
{
int retval;
- //if (s->had_expunges)
+/* if (s->had_expunges) */
retval = camel_folder_summary_save_rewrite (s, ex);
- //else
- // retval = camel_folder_summary_save_append (s, ex);
+/* else */
+/* retval = camel_folder_summary_save_append (s, ex); */
s->had_expunges = FALSE;
@@ -1273,10 +1262,10 @@
g_ptr_array_add(s->messages, info);
- g_mutex_lock (s->hash_lock);
+ g_static_rec_mutex_lock (s->hash_lock);
if (s->uidhash != NULL)
g_hash_table_insert (s->uidhash, g_strdup (info->uid), info);
- g_mutex_unlock (s->hash_lock);
+ g_static_rec_mutex_unlock (s->hash_lock);
s->flags |= CAMEL_SUMMARY_DIRTY;
@@ -1299,10 +1288,10 @@
g_ptr_array_add(s->messages, info);
- g_mutex_lock (s->hash_lock);
+ g_static_rec_mutex_lock (s->hash_lock);
if (s->uidhash != NULL)
g_hash_table_insert (s->uidhash, g_strdup (info->uid), info);
- g_mutex_unlock (s->hash_lock);
+ g_static_rec_mutex_unlock (s->hash_lock);
s->flags |= CAMEL_SUMMARY_DIRTY;
@@ -3759,6 +3748,10 @@
/* TODO: locking? */
old = mi->flags;
+ if (!(old & CAMEL_MESSAGE_INFO_NEEDS_FREE)
+ && (flags & set))
+ mi->summary->had_expunges = TRUE;
+
mi->flags = (old & ~flags) | (set & flags);
if (old != mi->flags) {
mi->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED;
Index: ChangeLog
===================================================================
--- ChangeLog (revision 3176)
+++ ChangeLog (working copy)
@@ -1,3 +1,11 @@
+2007-12-21 Jose Dapena Paz <jdapena igalia com>
+
+ * libtinymail-camel/camel-lite/camel/camel-folder-summary.c:
+ Use uid hash always when we try to fetch message info by uid.
+ Also small improvements for save_append operation. Not enough
+ yet to fix the operation, and then it's still disabled.
+
+
2007-12-21 Felipe Erias Morandeira <femorandeira igalia com>
* libtinymail/tny-mime-part.[hc] : changed the signature of
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]