[evolution-data-server] EDataBook: Have pending_ops hold OperationData references.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] EDataBook: Have pending_ops hold OperationData references.
- Date: Fri, 25 Jan 2013 16:15:08 +0000 (UTC)
commit 6b9b789f870fc78954333af6a3bc1086bfbe18c3
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Jan 25 10:45:23 2013 -0500
EDataBook: Have pending_ops hold OperationData references.
addressbook/libedata-book/e-data-book.c | 47 +++++++++++++++++-------------
1 files changed, 27 insertions(+), 20 deletions(-)
---
diff --git a/addressbook/libedata-book/e-data-book.c b/addressbook/libedata-book/e-data-book.c
index dafb58f..7177d49 100644
--- a/addressbook/libedata-book/e-data-book.c
+++ b/addressbook/libedata-book/e-data-book.c
@@ -46,7 +46,7 @@ struct _EDataBookPrivate {
gchar *object_path;
GRecMutex pending_ops_lock;
- GHashTable *pending_ops; /* opid to GCancellable for still running operations */
+ GHashTable *pending_ops; /* opid -> OperationData */
/* Operations are queued while an
* open operation is in progress. */
@@ -142,16 +142,6 @@ construct_bookview_path (void)
getpid (), counter);
}
-static void
-cancel_ops_cb (gpointer opid,
- gpointer cancellable,
- gpointer user_data)
-{
- g_return_if_fail (cancellable != NULL);
-
- g_cancellable_cancel (cancellable);
-}
-
static OperationData *
op_ref (OperationData *data)
{
@@ -177,7 +167,10 @@ op_new (OperationID op,
data->cancellable = g_cancellable_new ();
g_rec_mutex_lock (&book->priv->pending_ops_lock);
- g_hash_table_insert (book->priv->pending_ops, GUINT_TO_POINTER (data->id), g_object_ref (data->cancellable));
+ g_hash_table_insert (
+ book->priv->pending_ops,
+ GUINT_TO_POINTER (data->id),
+ op_ref (data));
g_rec_mutex_unlock (&book->priv->pending_ops_lock);
return data;
@@ -257,7 +250,9 @@ op_complete (EDataBook *book,
e_operation_pool_release_opid (ops_pool, opid);
g_rec_mutex_lock (&book->priv->pending_ops_lock);
- g_hash_table_remove (book->priv->pending_ops, GUINT_TO_POINTER (opid));
+ g_hash_table_remove (
+ book->priv->pending_ops,
+ GUINT_TO_POINTER (opid));
g_rec_mutex_unlock (&book->priv->pending_ops_lock);
}
@@ -266,7 +261,10 @@ operation_thread (gpointer data,
gpointer user_data)
{
OperationData *op = data;
+ OperationData *cancel_op;
EBookBackend *backend;
+ GHashTableIter iter;
+ gpointer value;
backend = e_data_book_get_backend (op->book);
@@ -353,11 +351,11 @@ operation_thread (gpointer data,
case OP_CANCEL_OPERATION:
g_rec_mutex_lock (&op->book->priv->pending_ops_lock);
- if (g_hash_table_lookup (op->book->priv->pending_ops, GUINT_TO_POINTER (op->d.opid))) {
- GCancellable *cancellable = g_hash_table_lookup (op->book->priv->pending_ops, GUINT_TO_POINTER (op->d.opid));
-
- g_cancellable_cancel (cancellable);
- }
+ cancel_op = g_hash_table_lookup (
+ op->book->priv->pending_ops,
+ GUINT_TO_POINTER (op->d.opid));
+ if (cancel_op != NULL)
+ g_cancellable_cancel (cancel_op->cancellable);
g_rec_mutex_unlock (&op->book->priv->pending_ops_lock);
break;
@@ -366,7 +364,13 @@ operation_thread (gpointer data,
e_book_backend_remove_client (backend, op->book);
case OP_CANCEL_ALL:
g_rec_mutex_lock (&op->book->priv->pending_ops_lock);
- g_hash_table_foreach (op->book->priv->pending_ops, cancel_ops_cb, NULL);
+
+ g_hash_table_iter_init (&iter, op->book->priv->pending_ops);
+ while (g_hash_table_iter_next (&iter, NULL, &value)) {
+ cancel_op = (OperationData *) value;
+ g_cancellable_cancel (cancel_op->cancellable);
+ }
+
g_rec_mutex_unlock (&op->book->priv->pending_ops_lock);
break;
}
@@ -1523,7 +1527,10 @@ e_data_book_init (EDataBook *ebook)
ebook->priv->dbus_interface = e_gdbus_book_stub_new ();
ebook->priv->pending_ops = g_hash_table_new_full (
- g_direct_hash, g_direct_equal, NULL, g_object_unref);
+ (GHashFunc) g_direct_hash,
+ (GEqualFunc) g_direct_equal,
+ (GDestroyNotify) NULL,
+ (GDestroyNotify) op_unref);
g_rec_mutex_init (&ebook->priv->pending_ops_lock);
g_mutex_init (&ebook->priv->open_lock);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]