[evolution-data-server] Bug 739610 - [IMAPx] Prevent running FETCH and STORE at the same time
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 739610 - [IMAPx] Prevent running FETCH and STORE at the same time
- Date: Wed, 12 Nov 2014 07:19:10 +0000 (UTC)
commit c61babe8ebb71207e5dce879e825bc29107b94ae
Author: Milan Crha <mcrha redhat com>
Date: Wed Nov 12 08:19:09 2014 +0100
Bug 739610 - [IMAPx] Prevent running FETCH and STORE at the same time
camel/providers/imapx/camel-imapx-mailbox.c | 20 ++++++++++++++++++++
camel/providers/imapx/camel-imapx-mailbox.h | 5 +++++
camel/providers/imapx/camel-imapx-server.c | 12 ++++++++++++
3 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-mailbox.c b/camel/providers/imapx/camel-imapx-mailbox.c
index f9b86ae..7da8b00 100644
--- a/camel/providers/imapx/camel-imapx-mailbox.c
+++ b/camel/providers/imapx/camel-imapx-mailbox.c
@@ -49,6 +49,7 @@ struct _CamelIMAPXMailboxPrivate {
guint32 permanentflags;
GMutex property_lock;
+ GRecMutex update_lock;
/* Protected by the "property_lock". */
GHashTable *attributes;
@@ -95,6 +96,7 @@ imapx_mailbox_finalize (GObject *object)
g_free (priv->name);
g_mutex_clear (&priv->property_lock);
+ g_rec_mutex_clear (&priv->update_lock);
g_hash_table_destroy (priv->attributes);
g_sequence_free (priv->message_map);
g_strfreev (priv->quota_roots);
@@ -121,6 +123,7 @@ camel_imapx_mailbox_init (CamelIMAPXMailbox *mailbox)
mailbox->priv = CAMEL_IMAPX_MAILBOX_GET_PRIVATE (mailbox);
g_mutex_init (&mailbox->priv->property_lock);
+ g_rec_mutex_init (&mailbox->priv->update_lock);
mailbox->priv->message_map = g_sequence_new (NULL);
mailbox->priv->permanentflags = ~0;
}
@@ -1145,3 +1148,20 @@ camel_imapx_mailbox_handle_status_response (CamelIMAPXMailbox *mailbox,
mailbox->priv->highestmodseq = value64;
}
+/* Prevents running FETCH and STORE at the same time for the given mailbox */
+void
+camel_imapx_mailbox_lock_update (CamelIMAPXMailbox *mailbox)
+{
+ g_return_if_fail (CAMEL_IS_IMAPX_MAILBOX (mailbox));
+
+ g_rec_mutex_lock (&mailbox->priv->update_lock);
+}
+
+/* Prevents running FETCH and STORE at the same time for the given mailbox */
+void
+camel_imapx_mailbox_unlock_update (CamelIMAPXMailbox *mailbox)
+{
+ g_return_if_fail (CAMEL_IS_IMAPX_MAILBOX (mailbox));
+
+ g_rec_mutex_unlock (&mailbox->priv->update_lock);
+}
diff --git a/camel/providers/imapx/camel-imapx-mailbox.h b/camel/providers/imapx/camel-imapx-mailbox.h
index 1dcd655..083d2ac 100644
--- a/camel/providers/imapx/camel-imapx-mailbox.h
+++ b/camel/providers/imapx/camel-imapx-mailbox.h
@@ -162,6 +162,11 @@ void camel_imapx_mailbox_handle_status_response
(CamelIMAPXMailbox *mailbox,
CamelIMAPXStatusResponse *response);
+void camel_imapx_mailbox_lock_update
+ (CamelIMAPXMailbox *mailbox);
+void camel_imapx_mailbox_unlock_update
+ (CamelIMAPXMailbox *mailbox);
+
G_END_DECLS
#endif /* CAMEL_IMAPX_MAILBOX_H */
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 8ac435c..f2e3394 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -8694,11 +8694,17 @@ camel_imapx_server_refresh_info (CamelIMAPXServer *is,
QUEUE_UNLOCK (is);
+ if (registered)
+ camel_imapx_mailbox_lock_update (mailbox);
+
if (registered && camel_imapx_job_run (job, is, error)) {
changes = data->changes;
data->changes = NULL;
}
+ if (registered)
+ camel_imapx_mailbox_unlock_update (mailbox);
+
camel_imapx_job_unref (job);
return changes;
@@ -9026,8 +9032,14 @@ imapx_server_sync_changes (CamelIMAPXServer *is,
QUEUE_UNLOCK (is);
+ if (job_type == IMAPX_JOB_SYNC_CHANGES && registered)
+ camel_imapx_mailbox_lock_update (mailbox);
+
success = registered && camel_imapx_job_run (job, is, error);
+ if (job_type == IMAPX_JOB_SYNC_CHANGES && registered)
+ camel_imapx_mailbox_unlock_update (mailbox);
+
camel_imapx_job_unref (job);
g_object_unref (folder);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]