[evolution-kolab/ek-wip-porting] CamelImapxMetadata: rework of metadata resection
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting] CamelImapxMetadata: rework of metadata resection
- Date: Fri, 20 Jul 2012 14:53:06 +0000 (UTC)
commit 30e81e1f202655335fc335dfbb56edba3b5d1359
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Fri Jul 20 16:46:05 2012 +0200
CamelImapxMetadata: rework of metadata resection
* instead of juggling with the GMutexes, which is
prone to segfaulting the threads waiting on them,
better switch the payload hash tables when
resecting
src/libekolab/camel-imapx-extd-store.c | 2 +-
src/libekolab/camel-imapx-metadata.c | 19 ++++++++-----------
src/libekolab/camel-imapx-metadata.h | 2 +-
3 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/src/libekolab/camel-imapx-extd-store.c b/src/libekolab/camel-imapx-extd-store.c
index 58b0fc7..bfef794 100644
--- a/src/libekolab/camel-imapx-extd-store.c
+++ b/src/libekolab/camel-imapx-extd-store.c
@@ -477,7 +477,7 @@ imapx_extd_store_get_metadata (CamelIMAPXExtdStore *self,
* the result inside this object for later resection
*/
if (do_resect)
- md = camel_imapx_metadata_resect (&(priv->md));
+ md = camel_imapx_metadata_resect (priv->md);
return md;
}
diff --git a/src/libekolab/camel-imapx-metadata.c b/src/libekolab/camel-imapx-metadata.c
index 2671a39..90d1212 100644
--- a/src/libekolab/camel-imapx-metadata.c
+++ b/src/libekolab/camel-imapx-metadata.c
@@ -181,27 +181,24 @@ camel_imapx_metadata_free (CamelImapxMetadata *md)
}
CamelImapxMetadata*
-camel_imapx_metadata_resect (CamelImapxMetadata **md)
+camel_imapx_metadata_resect (CamelImapxMetadata *md)
{
CamelImapxMetadata *tmp_md = NULL;
- GMutex tmp_lock;
+ GHashTable *mboxes = NULL;
if (md == NULL)
return NULL;
/* (acquire md lock) */
- g_mutex_lock (&((*md)->md_lock));
-
- tmp_md = *md;
- *md = camel_imapx_metadata_new (tmp_md->proto, FALSE);
+ g_mutex_lock (&(md->md_lock));
- /* (swap lock pointers of md and tmp_md) */
- tmp_lock = tmp_md->md_lock; /* locked */
- tmp_md->md_lock = (*md)->md_lock; /* unlocked */
- (*md)->md_lock = tmp_lock; /* locked */
+ tmp_md = camel_imapx_metadata_new (md->proto, FALSE);
+ mboxes = md->mboxes;
+ md->mboxes = tmp_md->mboxes;
+ tmp_md->mboxes = mboxes;
/* (release md lock) */
- g_mutex_unlock (&((*md)->md_lock));
+ g_mutex_unlock (&(md->md_lock));
return tmp_md;
}
diff --git a/src/libekolab/camel-imapx-metadata.h b/src/libekolab/camel-imapx-metadata.h
index 8806ad6..1a519d7 100644
--- a/src/libekolab/camel-imapx-metadata.h
+++ b/src/libekolab/camel-imapx-metadata.h
@@ -136,7 +136,7 @@ camel_imapx_metadata_new (camel_imapx_metadata_proto_t proto,
gboolean locked);
CamelImapxMetadata*
-camel_imapx_metadata_resect (CamelImapxMetadata **md);
+camel_imapx_metadata_resect (CamelImapxMetadata *md);
void
camel_imapx_metadata_free (CamelImapxMetadata *md);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]