[evolution-data-server/evolution-data-server-3-12] Bug 731562 - [IMAPx] Occasionally getting 'Empty cache file' error
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/evolution-data-server-3-12] Bug 731562 - [IMAPx] Occasionally getting 'Empty cache file' error
- Date: Mon, 16 Jun 2014 13:02:29 +0000 (UTC)
commit 41a795bb0eff6dddce0164b0f4629f7f237fcd61
Author: Milan Crha <mcrha redhat com>
Date: Mon Jun 16 15:01:33 2014 +0200
Bug 731562 - [IMAPx] Occasionally getting 'Empty cache file' error
camel/providers/imapx/camel-imapx-command.c | 8 ++++++-
camel/providers/imapx/camel-imapx-job.c | 30 +++++++++++++++++++++++++++
camel/providers/imapx/camel-imapx-job.h | 3 ++
camel/providers/imapx/camel-imapx-server.c | 25 +++++++++++++++++++++-
4 files changed, 64 insertions(+), 2 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-command.c b/camel/providers/imapx/camel-imapx-command.c
index fa94768..839aa97 100644
--- a/camel/providers/imapx/camel-imapx-command.c
+++ b/camel/providers/imapx/camel-imapx-command.c
@@ -596,7 +596,10 @@ camel_imapx_command_failed (CamelIMAPXCommand *ic,
g_return_if_fail (error != NULL);
real_ic = (CamelIMAPXRealCommand *) ic;
- g_return_if_fail (real_ic->error == NULL);
+
+ /* Do not overwrite errors, the first passed in wins */
+ if (real_ic->error != NULL)
+ return;
real_ic->error = g_error_copy (error);
}
@@ -643,6 +646,9 @@ camel_imapx_command_set_error_if_failed (CamelIMAPXCommand *ic,
return TRUE;
}
+ if (real_ic->job)
+ return camel_imapx_job_set_error_if_failed (real_ic->job, error);
+
return FALSE;
}
diff --git a/camel/providers/imapx/camel-imapx-job.c b/camel/providers/imapx/camel-imapx-job.c
index 52aef02..a70a4b6 100644
--- a/camel/providers/imapx/camel-imapx-job.c
+++ b/camel/providers/imapx/camel-imapx-job.c
@@ -417,3 +417,33 @@ camel_imapx_job_take_error (CamelIMAPXJob *job,
real_job->error = error; /* takes ownership */
}
+/**
+ * camel_imapx_job_set_error_if_failed:
+ * @job: a #CamelIMAPXJob
+ * @error: a location for a #GError
+ *
+ * Sets @error to a new GError instance and returns TRUE, if the job has set
+ * an error or when it was cancelled.
+ *
+ * Returns: Whether the job failed.
+ *
+ * Since: 3.12.4
+ **/
+gboolean
+camel_imapx_job_set_error_if_failed (CamelIMAPXJob *job,
+ GError **error)
+{
+ CamelIMAPXRealJob *real_job;
+
+ g_return_val_if_fail (CAMEL_IS_IMAPX_JOB (job), TRUE);
+ g_return_val_if_fail (error != NULL, TRUE);
+
+ real_job = (CamelIMAPXRealJob *) job;
+
+ if (real_job->error) {
+ g_propagate_error (error, g_error_copy (real_job->error));
+ return TRUE;
+ }
+
+ return g_cancellable_set_error_if_cancelled (real_job->cancellable, error);
+}
diff --git a/camel/providers/imapx/camel-imapx-job.h b/camel/providers/imapx/camel-imapx-job.h
index c3acc28..884c10a 100644
--- a/camel/providers/imapx/camel-imapx-job.h
+++ b/camel/providers/imapx/camel-imapx-job.h
@@ -80,6 +80,9 @@ void camel_imapx_job_set_mailbox (CamelIMAPXJob *job,
GCancellable * camel_imapx_job_get_cancellable (CamelIMAPXJob *job);
void camel_imapx_job_take_error (CamelIMAPXJob *job,
GError *error);
+gboolean camel_imapx_job_set_error_if_failed
+ (CamelIMAPXJob *job,
+ GError **error);
G_END_DECLS
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 962f7a0..7d89c61 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1383,7 +1383,9 @@ imapx_command_start_next (CamelIMAPXServer *is)
return;
}
+ g_mutex_lock (&is->priv->select_lock);
mailbox = g_weak_ref_get (&is->priv->select_pending);
+ g_mutex_unlock (&is->priv->select_lock);
if (mailbox != NULL) {
CamelIMAPXCommand *start_ic = NULL;
GList *head, *link;
@@ -1488,7 +1490,9 @@ imapx_command_start_next (CamelIMAPXServer *is)
}
/* See if any queued jobs on this select first */
+ g_mutex_lock (&is->priv->select_lock);
mailbox = g_weak_ref_get (&is->priv->select_mailbox);
+ g_mutex_unlock (&is->priv->select_lock);
if (mailbox != NULL) {
CamelIMAPXCommand *start_ic = NULL;
GList *head, *link;
@@ -1611,7 +1615,9 @@ imapx_command_start_next (CamelIMAPXServer *is)
min_pri = first_ic->pri;
+ g_mutex_lock (&is->priv->select_lock);
mailbox = g_weak_ref_get (&is->priv->select_mailbox);
+ g_mutex_unlock (&is->priv->select_lock);
head = camel_imapx_command_queue_peek_head_link (is->queue);
@@ -1749,7 +1755,10 @@ imapx_match_active_job (CamelIMAPXServer *is,
if (!(job->type & type))
continue;
+ g_mutex_lock (&is->priv->select_lock);
mailbox = g_weak_ref_get (&is->priv->select_mailbox);
+ g_mutex_unlock (&is->priv->select_lock);
+
job_matches = camel_imapx_job_matches (job, mailbox, uid);
g_clear_object (&mailbox);
@@ -1804,7 +1813,10 @@ imapx_expunge_uid_from_summary (CamelIMAPXServer *is,
CamelMessageInfo *mi;
guint32 messages;
+ g_mutex_lock (&is->priv->select_lock);
mailbox = g_weak_ref_get (&is->priv->select_mailbox);
+ g_mutex_unlock (&is->priv->select_lock);
+
g_return_if_fail (mailbox != NULL);
folder = imapx_server_ref_folder (is, mailbox);
@@ -1887,7 +1899,9 @@ imapx_untagged_expunge (CamelIMAPXServer *is,
c (is->tagprefix, "expunged: %lu\n", is->priv->context->id);
+ g_mutex_lock (&is->priv->select_lock);
mailbox = g_weak_ref_get (&is->priv->select_mailbox);
+ g_mutex_unlock (&is->priv->select_lock);
if (mailbox != NULL) {
CamelFolder *folder;
@@ -1953,7 +1967,10 @@ imapx_untagged_vanished (CamelIMAPXServer *is,
if (uids == NULL)
return FALSE;
+ g_mutex_lock (&is->priv->select_lock);
mailbox = g_weak_ref_get (&is->priv->select_mailbox);
+ g_mutex_unlock (&is->priv->select_lock);
+
g_return_val_if_fail (mailbox != NULL, FALSE);
folder = imapx_server_ref_folder (is, mailbox);
@@ -1987,7 +2004,7 @@ imapx_untagged_vanished (CamelIMAPXServer *is,
uid = g_array_index (uids, guint32, ii);
- c (is->tagprefix, "vanished: %u\n", uid);
+ e (is->tagprefix, "vanished: %u\n", uid);
str = g_strdup_printf ("%u", uid);
uid_list = g_list_prepend (uid_list, str);
@@ -3254,7 +3271,10 @@ imapx_completion (CamelIMAPXServer *is,
CamelFolder *folder;
CamelIMAPXMailbox *mailbox;
+ g_mutex_lock (&is->priv->select_lock);
mailbox = g_weak_ref_get (&is->priv->select_mailbox);
+ g_mutex_unlock (&is->priv->select_lock);
+
g_return_val_if_fail (mailbox != NULL, FALSE);
folder = imapx_server_ref_folder (is, mailbox);
@@ -3663,7 +3683,10 @@ imapx_call_idle (gpointer data)
if (is->priv->idle_state != IMAPX_IDLE_PENDING)
goto exit;
+ g_mutex_lock (&is->priv->select_lock);
mailbox = g_weak_ref_get (&is->priv->select_mailbox);
+ g_mutex_unlock (&is->priv->select_lock);
+
if (mailbox == NULL)
goto exit;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]