[telepathy-mission-control/master] McdDispatchOperation: add the "invoking early clients" temporary lock

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Oct 20 08:47:22 PDT 2009


---
 src/mcd-dispatch-operation-priv.h |    6 ++++++
 src/mcd-dispatch-operation.c      |   22 ++++++++++++++++++++++
 src/mcd-dispatcher.c              |   13 +++++--------
 3 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/src/mcd-dispatch-operation-priv.h b/src/mcd-dispatch-operation-priv.h
index 0becc2b..9f109bf 100644
--- a/src/mcd-dispatch-operation-priv.h
+++ b/src/mcd-dispatch-operation-priv.h
@@ -120,6 +120,12 @@ G_GNUC_INTERNAL void _mcd_dispatch_operation_inc_ado_pending (
 G_GNUC_INTERNAL void _mcd_dispatch_operation_dec_ado_pending (
     McdDispatchOperation *self);
 
+/* Temporary client lock while starting observers/approvers */
+G_GNUC_INTERNAL gboolean _mcd_dispatch_operation_is_invoking_early_clients (
+    McdDispatchOperation *self);
+G_GNUC_INTERNAL void _mcd_dispatch_operation_set_invoking_early_clients (
+    McdDispatchOperation *self, gboolean value);
+
 G_END_DECLS
 
 #endif
diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index 884cf0c..06d2ace 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -110,6 +110,12 @@ struct _McdDispatchOperationPrivate
      * or a client approved processing with arbitrary handlers */
     gboolean approved;
 
+    /* If TRUE, we're still working out what Observers and Approvers to
+     * run. This is a temporary client lock; a reference must be held
+     * while it is TRUE (in the McdDispatcherContext, CTXREF07 ensures this).
+     */
+    gboolean invoking_early_clients;
+
     /* The number of observers that have not yet returned from ObserveChannels.
      * Until they have done so, we can't allow the dispatch operation to
      * finish. This is a client lock.
@@ -207,6 +213,22 @@ _mcd_dispatch_operation_dec_ado_pending (McdDispatchOperation *self)
     g_object_unref (self);
 }
 
+gboolean
+_mcd_dispatch_operation_is_invoking_early_clients (McdDispatchOperation *self)
+{
+    g_return_val_if_fail (MCD_IS_DISPATCH_OPERATION (self), FALSE);
+    return self->priv->invoking_early_clients;
+}
+
+void
+_mcd_dispatch_operation_set_invoking_early_clients (McdDispatchOperation *self,
+                                                    gboolean value)
+{
+    g_return_if_fail (MCD_IS_DISPATCH_OPERATION (self));
+    g_return_if_fail (self->priv->invoking_early_clients == !value);
+    self->priv->invoking_early_clients = value;
+}
+
 enum
 {
     PROP_0,
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index c782120..3e6e641 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -99,11 +99,6 @@ struct _McdDispatcherContext
      * CTXREF14 is held while we await approval. */
     guint awaiting_approval : 1;
 
-    /* If TRUE, we're still working out what Observers and Approvers to
-     * run. This is a temporary client lock. CTXREF07 is held while this
-     * lock is active. */
-    guint invoking_clients : 1;
-
     /* If TRUE, either we've already arranged for the channels to get a
      * handler, or there are no channels left. */
     guint channels_handled : 1;
@@ -887,7 +882,7 @@ finally:
 static void
 mcd_dispatcher_context_check_client_locks (McdDispatcherContext *context)
 {
-    if (!context->invoking_clients &&
+    if (!_mcd_dispatch_operation_is_invoking_early_clients (context->operation) &&
         !_mcd_dispatch_operation_has_observers_pending (context->operation) &&
         _mcd_dispatch_operation_is_approved (context->operation))
     {
@@ -1195,7 +1190,8 @@ static void
 mcd_dispatcher_run_clients (McdDispatcherContext *context)
 {
     mcd_dispatcher_context_ref (context, "CTXREF07");
-    context->invoking_clients = TRUE;
+    _mcd_dispatch_operation_set_invoking_early_clients (context->operation,
+                                                        TRUE);
 
     mcd_dispatcher_run_observers (context);
 
@@ -1216,7 +1212,8 @@ mcd_dispatcher_run_clients (McdDispatcherContext *context)
             mcd_dispatcher_run_approvers (context);
     }
 
-    context->invoking_clients = FALSE;
+    _mcd_dispatch_operation_set_invoking_early_clients (context->operation,
+                                                        FALSE);
     mcd_dispatcher_context_check_client_locks (context);
     mcd_dispatcher_context_unref (context, "CTXREF07");
 }
-- 
1.5.6.5




More information about the telepathy-commits mailing list