[evolution-data-server] Lock the search.
- From: Chenthill Palanisamy <pchen src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Lock the search.
- Date: Wed, 2 Dec 2009 10:44:33 +0000 (UTC)
commit b6cc66db5bcb63bb6a12c52358bb605670b655b0
Author: Chenthill Palanisamy <pchenthill novell com>
Date: Tue Dec 1 18:28:39 2009 +0530
Lock the search.
camel/providers/imapx/camel-imapx-folder.c | 24 +++++++++++++++++++++++-
camel/providers/imapx/camel-imapx-folder.h | 2 +-
2 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index 4a07856..dd841a5 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -71,13 +71,14 @@ camel_imapx_folder_new(CamelStore *store, const gchar *path, const gchar *folder
folder = CAMEL_FOLDER (camel_object_new (CAMEL_IMAPX_FOLDER_TYPE));
camel_folder_construct(folder, store, folder_name, short_name);
- ifolder = folder;
+ ifolder = (CamelIMAPXFolder *) folder;
((CamelIMAPXFolder *)folder)->raw_name = g_strdup(folder_name);
summary_file = g_strdup_printf ("%s/summary", path);
folder->summary = camel_imapx_summary_new(folder, summary_file);
ifolder->search = camel_folder_search_new ();
+ ifolder->search_lock = g_mutex_new ();
g_free (summary_file);
@@ -236,7 +237,11 @@ imapx_search_free (CamelFolder *folder, GPtrArray *uids)
g_return_if_fail (ifolder->search);
+ g_mutex_lock (ifolder->search_lock);
+
camel_folder_search_free_result (ifolder->search, uids);
+
+ g_mutex_unlock (ifolder->search_lock);
}
static GPtrArray *
@@ -248,8 +253,12 @@ imapx_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *u
if (uids->len == 0)
return g_ptr_array_new();
+ g_mutex_lock (ifolder->search_lock);
+
camel_folder_search_set_folder(ifolder->search, folder);
matches = camel_folder_search_search(ifolder->search, expression, uids, ex);
+
+ g_mutex_unlock (ifolder->search_lock);
return matches;
}
@@ -260,9 +269,13 @@ imapx_count_by_expression (CamelFolder *folder, const gchar *expression, CamelEx
CamelIMAPXFolder *ifolder = CAMEL_IMAPX_FOLDER(folder);
guint32 matches;
+ g_mutex_lock (ifolder->search_lock);
+
camel_folder_search_set_folder (ifolder->search, folder);
matches = camel_folder_search_count (ifolder->search, expression, ex);
+ g_mutex_unlock (ifolder->search_lock);
+
return matches;
}
@@ -272,9 +285,13 @@ imapx_search_by_expression (CamelFolder *folder, const gchar *expression, CamelE
CamelIMAPXFolder *ifolder = CAMEL_IMAPX_FOLDER (folder);
GPtrArray *matches;
+ g_mutex_lock (ifolder->search_lock);
+
camel_folder_search_set_folder (ifolder->search, folder);
matches = camel_folder_search_search(ifolder->search, expression, NULL, ex);
+ g_mutex_unlock (ifolder->search_lock);
+
return matches;
}
@@ -309,6 +326,11 @@ imap_folder_init(CamelObject *o, CamelObjectClass *klass)
static void
imap_finalise(CamelObject *object)
{
+ CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) object;
+
+ g_mutex_free (ifolder->search_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 a6c3a6c..2cf4db7 100644
--- a/camel/providers/imapx/camel-imapx-folder.h
+++ b/camel/providers/imapx/camel-imapx-folder.h
@@ -41,7 +41,7 @@ typedef struct _CamelIMAPXFolder {
gchar *raw_name;
CamelFolderSearch *search;
-// CamelChangeInfo *changes;
+ GMutex *search_lock;
} CamelIMAPXFolder;
typedef struct _CamelIMAPXFolderClass {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]