summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author4 <NotZed@Ximian.com>2001-11-30 21:30:47 +0000
committerMichael Zucci <zucchi@src.gnome.org>2001-11-30 21:30:47 +0000
commit8de87e9694a3586e80ff4bd8b6a94ec149b99b53 (patch)
tree196bc0f459f69e12b97f95d74f8b349ea6eedeff
parentc76b3ac7f2b8ec5f8c3dc77ea518d305faad3720 (diff)
downloadevolution-data-server-8de87e9694a3586e80ff4bd8b6a94ec149b99b53.tar.gz
Use the uid rather than vuid for unmatched. Also add the uid to unmatched
2001-11-14 <NotZed@Ximian.com> * camel-vee-folder.c (folder_changed_remove_uid): Use the uid rather than vuid for unmatched. Also add the uid to unmatched if it wasn't in the unmatched_uids table at all. (folder_changed_change): If checking for added, if the new ones dont match, then try to add them to unmatched. Fixes #6893. * camel-folder-summary.c (camel_folder_summary_index): Change lock order, always summary_lock before ref_lock. (camel_folder_summary_array): " (camel_folder_summary_uid): " (camel_folder_summary_remove_uid): " Fixes a deadlock.
-rw-r--r--camel/ChangeLog14
-rw-r--r--camel/camel-folder-summary.c20
-rw-r--r--camel/camel-vee-folder.c38
3 files changed, 57 insertions, 15 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 6a860b5c0..a984a09f2 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,17 @@
+2001-11-14 <NotZed@Ximian.com>
+
+ * camel-vee-folder.c (folder_changed_remove_uid): Use the uid
+ rather than vuid for unmatched. Also add the uid to unmatched if
+ it wasn't in the unmatched_uids table at all.
+ (folder_changed_change): If checking for added, if the new ones
+ dont match, then try to add them to unmatched. Fixes #6893.
+
+ * camel-folder-summary.c (camel_folder_summary_index): Change lock
+ order, always summary_lock before ref_lock.
+ (camel_folder_summary_array): "
+ (camel_folder_summary_uid): "
+ (camel_folder_summary_remove_uid): " Fixes a deadlock.
+
2001-11-21 Jeffrey Stedfast <fejj@ximian.com>
* Makefile.am: Remove OpenSSL library includes/LDFLAGS from the
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 8cc355b26..2591e868a 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -336,18 +336,17 @@ camel_folder_summary_index(CamelFolderSummary *s, int i)
{
CamelMessageInfo *info = NULL;
- CAMEL_SUMMARY_LOCK(s, ref_lock);
CAMEL_SUMMARY_LOCK(s, summary_lock);
+ CAMEL_SUMMARY_LOCK(s, ref_lock);
if (i<s->messages->len)
info = g_ptr_array_index(s->messages, i);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
-
if (info)
info->refcount++;
CAMEL_SUMMARY_UNLOCK(s, ref_lock);
+ CAMEL_SUMMARY_UNLOCK(s, summary_lock);
return info;
}
@@ -369,8 +368,8 @@ camel_folder_summary_array(CamelFolderSummary *s)
GPtrArray *res = g_ptr_array_new();
int i;
- CAMEL_SUMMARY_LOCK(s, ref_lock);
CAMEL_SUMMARY_LOCK(s, summary_lock);
+ CAMEL_SUMMARY_LOCK(s, ref_lock);
g_ptr_array_set_size(res, s->messages->len);
for (i=0;i<s->messages->len;i++) {
@@ -378,8 +377,8 @@ camel_folder_summary_array(CamelFolderSummary *s)
info->refcount++;
}
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
CAMEL_SUMMARY_UNLOCK(s, ref_lock);
+ CAMEL_SUMMARY_UNLOCK(s, summary_lock);
return res;
}
@@ -421,17 +420,16 @@ camel_folder_summary_uid(CamelFolderSummary *s, const char *uid)
{
CamelMessageInfo *info;
- CAMEL_SUMMARY_LOCK(s, ref_lock);
CAMEL_SUMMARY_LOCK(s, summary_lock);
+ CAMEL_SUMMARY_LOCK(s, ref_lock);
info = g_hash_table_lookup(s->messages_uid, uid);
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
-
if (info)
info->refcount++;
CAMEL_SUMMARY_UNLOCK(s, ref_lock);
+ CAMEL_SUMMARY_UNLOCK(s, summary_lock);
return info;
}
@@ -1062,18 +1060,18 @@ void camel_folder_summary_remove_uid(CamelFolderSummary *s, const char *uid)
CamelMessageInfo *oldinfo;
char *olduid;
- CAMEL_SUMMARY_LOCK(s, ref_lock);
CAMEL_SUMMARY_LOCK(s, summary_lock);
+ CAMEL_SUMMARY_LOCK(s, ref_lock);
if (g_hash_table_lookup_extended(s->messages_uid, uid, (void *)&olduid, (void *)&oldinfo)) {
/* make sure it doesn't vanish while we're removing it */
oldinfo->refcount++;
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
CAMEL_SUMMARY_UNLOCK(s, ref_lock);
+ CAMEL_SUMMARY_UNLOCK(s, summary_lock);
camel_folder_summary_remove(s, oldinfo);
camel_folder_summary_info_free(s, oldinfo);
} else {
- CAMEL_SUMMARY_UNLOCK(s, summary_lock);
CAMEL_SUMMARY_UNLOCK(s, ref_lock);
+ CAMEL_SUMMARY_UNLOCK(s, summary_lock);
}
}
diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c
index 5ddd90d5b..c7f7be98f 100644
--- a/camel/camel-vee-folder.c
+++ b/camel/camel-vee-folder.c
@@ -1166,12 +1166,15 @@ folder_changed_remove_uid(CamelFolder *sub, const char *uid, const char hash[8],
if (g_hash_table_lookup_extended(unmatched_uids, vuid, (void **)&oldkey, (void **)&n)) {
if (n == 1) {
g_hash_table_remove(unmatched_uids, oldkey);
- if (vee_folder_add_uid(folder_unmatched, sub, vuid, hash))
+ if (vee_folder_add_uid(folder_unmatched, sub, uid, hash))
camel_folder_change_info_add_uid(folder_unmatched->changes, oldkey);
g_free(oldkey);
} else {
g_hash_table_insert(unmatched_uids, oldkey, (void *)(n-1));
}
+ } else {
+ if (vee_folder_add_uid(folder_unmatched, sub, uid, hash))
+ camel_folder_change_info_add_uid(folder_unmatched->changes, oldkey);
}
} else {
if (g_hash_table_lookup_extended(unmatched_uids, vuid, (void **)&oldkey, (void **)&n)) {
@@ -1343,12 +1346,39 @@ folder_changed_change(CamelSession *session, CamelSessionThreadMsg *msg)
folder_changed_remove_uid(sub, changes->uid_removed->pdata[i], hash, FALSE, vf);
}
- /* Add any newly matched */
+ /* Add any newly matched or to unmatched folder if they dont */
if (matches_added) {
+ matches_hash = g_hash_table_new(g_str_hash, g_str_equal);
for (i=0;i<matches_added->len;i++) {
- dd(printf(" adding uid '%s' [newly matched]\n", (char *)matches_added->pdata[i]));
- folder_changed_add_uid(sub, matches_added->pdata[i], hash, vf);
+ dd(printf(" %s", (char *)matches_added->pdata[i]));
+ g_hash_table_insert(matches_hash, matches_added->pdata[i], matches_added->pdata[i]);
}
+ for (i=0;i<changes->uid_added->len;i++) {
+ uid = changes->uid_added->pdata[i];
+ if (g_hash_table_lookup(matches_hash, uid)) {
+ dd(printf(" adding uid '%s' [newly matched]\n", (char *)uid));
+ folder_changed_add_uid(sub, uid, hash, vf);
+ } else if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0) {
+ if (strlen(uid)+9 > vuidlen) {
+ vuidlen = strlen(uid)+64;
+ vuid = g_realloc(vuid, vuidlen);
+ }
+ memcpy(vuid, hash, 8);
+ strcpy(vuid+8, uid);
+
+ if (g_hash_table_lookup(unmatched_uids, vuid) == NULL) {
+ dd(printf(" adding uid '%s' to Unmatched [newly unmatched]\n", (char *)uid));
+ vinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info((CamelFolder *)folder_unmatched, vuid);
+ if (vinfo == NULL) {
+ if (vee_folder_add_uid(folder_unmatched, sub, uid, hash))
+ camel_folder_change_info_add_uid(folder_unmatched->changes, vuid);
+ } else {
+ camel_folder_free_message_info((CamelFolder *)folder_unmatched, (CamelMessageInfo *)vinfo);
+ }
+ }
+ }
+ }
+ g_hash_table_destroy(matches_hash);
}
/* Change any newly changed */