[evolution-data-server] Bug 612383 - [IMAPX] Error while filtering message
- From: Chenthill Palanisamy <pchen src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 612383 - [IMAPX] Error while filtering message
- Date: Mon, 15 Mar 2010 11:48:04 +0000 (UTC)
commit efe72456655ce7ccb19b94e5eb1179751a2325d7
Author: Chenthill Palanisamy <pchenthill novell com>
Date: Mon Mar 15 17:17:34 2010 +0530
Bug 612383 - [IMAPX] Error while filtering message
camel/providers/imapx/camel-imapx-folder.c | 5 +++
camel/providers/imapx/camel-imapx-folder.h | 1 +
camel/providers/imapx/camel-imapx-server.c | 42 +++++++++++++++++++++------
camel/providers/imapx/camel-imapx-server.h | 3 ++
4 files changed, 41 insertions(+), 10 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index b2de265..38fdce7 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -103,6 +103,7 @@ camel_imapx_folder_new(CamelStore *store, const gchar *folder_dir, const gchar *
ifolder->search = camel_folder_search_new ();
ifolder->search_lock = g_mutex_new ();
+ ifolder->stream_lock = g_mutex_new ();
ifolder->ignore_recent = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
ifolder->exists_on_server = 0;
ifolder->unread_on_server = 0;
@@ -209,10 +210,13 @@ imapx_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
if (!camel_exception_is_set (ex) && stream) {
msg = camel_mime_message_new();
+
+ g_mutex_lock (ifolder->stream_lock);
if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg, stream) == -1) {
camel_object_unref(msg);
msg = NULL;
}
+ g_mutex_unlock (ifolder->stream_lock);
camel_object_unref(stream);
}
@@ -437,6 +441,7 @@ imapx_finalize (CamelObject *object)
g_hash_table_unref (ifolder->ignore_recent);
g_mutex_free (ifolder->search_lock);
+ g_mutex_free (ifolder->stream_lock);
if (ifolder->search)
camel_object_unref (CAMEL_OBJECT (ifolder->search));
}
diff --git a/camel/providers/imapx/camel-imapx-folder.h b/camel/providers/imapx/camel-imapx-folder.h
index 3a385a2..f01932f 100644
--- a/camel/providers/imapx/camel-imapx-folder.h
+++ b/camel/providers/imapx/camel-imapx-folder.h
@@ -52,6 +52,7 @@ typedef struct _CamelIMAPXFolder {
GHashTable *ignore_recent;
GMutex *search_lock;
+ GMutex *stream_lock;
} CamelIMAPXFolder;
typedef struct _CamelIMAPXFolderClass {
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index f708a77..22d5ab1 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -847,7 +847,7 @@ imapx_command_start_next(CamelIMAPXServer *is, CamelException *ex)
c(printf("- we're selected on '%s', current jobs?\n", is->select));
for (ic = (CamelIMAPXCommand *)is->active.head;ic->next;ic=ic->next) {
c(printf("- %3d '%s'\n", (gint)ic->pri, ic->name));
- if (ic->select && ic->pri > pri)
+ if (ic->pri > pri)
pri = ic->pri;
count++;
if (count > MAX_COMMANDS) {
@@ -2445,6 +2445,8 @@ imapx_command_fetch_message_done(CamelIMAPXServer *is, CamelIMAPXCommand *ic)
camel_exception_setv(job->ex, 1, "Error fetching message: %s", ic->status->text);
else
camel_exception_xfer (job->ex, ic->ex);
+ camel_object_unref (stream);
+ job->u.get_message.stream = NULL;
} else {
CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) job->folder;
@@ -2466,10 +2468,10 @@ imapx_command_fetch_message_done(CamelIMAPXServer *is, CamelIMAPXCommand *ic)
camel_exception_setv(job->ex, 1, "closing tmp stream failed: %s", g_strerror(errno));
g_free (tmp);
+ job->u.get_message.stream = camel_data_cache_get (ifolder->cache, "cur", job->u.get_message.uid, NULL);
}
}
- camel_object_unref (stream);
camel_data_cache_remove (ifolder->cache, "tmp", job->u.get_message.uid, NULL);
imapx_job_done (is, job);
}
@@ -2478,7 +2480,7 @@ imapx_command_fetch_message_done(CamelIMAPXServer *is, CamelIMAPXCommand *ic)
}
static void
-imapx_job_get_message_start(CamelIMAPXServer *is, CamelIMAPXJob *job)
+imapx_job_get_message_start (CamelIMAPXServer *is, CamelIMAPXJob *job)
{
CamelIMAPXCommand *ic;
gint i;
@@ -3766,6 +3768,8 @@ imapx_server_init(CamelIMAPXServer *is, CamelIMAPXServerClass *isclass)
is->expunged = NULL;
is->changes = camel_folder_change_info_new ();
is->parser_quit = FALSE;
+
+ is->uid_eflags = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify) e_flag_free);
}
static void
@@ -3773,6 +3777,7 @@ imapx_server_finalise(CamelIMAPXServer *is, CamelIMAPXServerClass *isclass)
{
g_static_rec_mutex_free(&is->queue_lock);
g_static_rec_mutex_free (&is->ostream_lock);
+ g_hash_table_destroy (is->uid_eflags);
camel_folder_change_info_free (is->changes);
}
@@ -3904,6 +3909,7 @@ imapx_server_get_message (CamelIMAPXServer *is, CamelFolder *folder, CamelOperat
gchar *cache_file = NULL;
CamelMessageInfo *mi;
gboolean registered;
+ EFlag *flag = NULL;
cache_file = camel_data_cache_get_filename (ifolder->cache, "cur", uid, NULL);
if (g_file_test (cache_file, G_FILE_TEST_EXISTS)) {
@@ -3915,12 +3921,19 @@ imapx_server_get_message (CamelIMAPXServer *is, CamelFolder *folder, CamelOperat
QUEUE_LOCK (is);
if ((job = imapx_is_job_in_queue (is, folder->full_name, IMAPX_JOB_GET_MESSAGE, uid))) {
+ flag = g_hash_table_lookup (is->uid_eflags, uid);
+
if (pri > job->pri)
job->pri = pri;
-
- camel_exception_set (ex, CAMEL_EXCEPTION_OPERATION_IN_PROGRESS, "Downloading message...");
+
QUEUE_UNLOCK (is);
- return NULL;
+
+ e_flag_wait (flag);
+
+ stream = camel_data_cache_get (ifolder->cache, "cur", uid, NULL);
+ if (!stream)
+ camel_exception_set (ex, 1, "Could not retrieve the message");
+ return stream;
}
mi = camel_folder_summary_uid (folder->summary, uid);
@@ -3951,16 +3964,25 @@ imapx_server_get_message (CamelIMAPXServer *is, CamelFolder *folder, CamelOperat
job->u.get_message.size = ((CamelMessageInfoBase *) mi)->size;
camel_message_info_free (mi);
registered = imapx_register_job (is, job);
+ flag = e_flag_new ();
+ g_hash_table_insert (is->uid_eflags, g_strdup (uid), flag);
QUEUE_UNLOCK (is);
- if (registered) {
+ if (registered)
imapx_run_job(is, job);
- stream = camel_data_cache_get (ifolder->cache, "cur", uid, NULL);
- }
-
+
+ e_flag_set (flag);
+ if (!camel_exception_is_set (job->ex))
+ stream = job->u.get_message.stream;
+
g_free(job);
+ /* HACK FIXME just sleep for sometime so that the other waiting locks gets released by that time. Think of a
+ better way..*/
+ g_usleep (1000);
+ g_hash_table_remove (is->uid_eflags, uid);
+
return stream;
}
diff --git a/camel/providers/imapx/camel-imapx-server.h b/camel/providers/imapx/camel-imapx-server.h
index bf1d74c..8573d66 100644
--- a/camel/providers/imapx/camel-imapx-server.h
+++ b/camel/providers/imapx/camel-imapx-server.h
@@ -100,6 +100,9 @@ struct _CamelIMAPXServer {
/* Idle */
struct _CamelIMAPXIdle *idle;
gboolean use_idle;
+
+ /* used for storing eflags to syncronize duplicate get_message requests */
+ GHashTable *uid_eflags;
};
struct _CamelIMAPXServerClass {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]