summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2010-10-13 11:02:26 +0100
committerWill Thompson <will.thompson@collabora.co.uk>2010-10-13 11:02:26 +0100
commit3b3b92fb7c369a0b23276d276ae91ad92b24c20a (patch)
tree23fdf8299e7aed3651fabcb3cc256642196dbc6b
parent29c76ba3085e2bc30f816160c2e0562eaeffb590 (diff)
downloadtelepathy-logger-3b3b92fb7c369a0b23276d276ae91ad92b24c20a.tar.gz
Ensure we always return from ObserveChannels
If we chose to ignore any of the channels passed to ObserveChannels, we'd previously never hit zero, and thus never return. In particular, if there was only one channel and we ignored it, we would never even check if we're ready to return.
-rw-r--r--telepathy-logger/observer.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/telepathy-logger/observer.c b/telepathy-logger/observer.c
index 3916a57..43095a7 100644
--- a/telepathy-logger/observer.c
+++ b/telepathy-logger/observer.c
@@ -106,6 +106,8 @@ typedef struct
TpObserveChannelsContext *ctx;
} ObservingContext;
+static gboolean observing_context_try_to_return (ObservingContext *ctx);
+
static TplObserver *observer_singleton = NULL;
enum
@@ -154,7 +156,10 @@ tpl_observer_observe_channels (TpBaseClient *client,
/* Ignore channel if we are already observing it */
if (g_hash_table_lookup (self->priv->channels, path) != NULL ||
g_hash_table_lookup (self->priv->preparing_channels, path) != NULL)
- continue;
+ {
+ observing_ctx->chan_n--;
+ continue;
+ }
/* d.bus.propertyName.str/gvalue hash */
prop_map = tp_channel_borrow_immutable_properties (channel);
@@ -164,8 +169,9 @@ tpl_observer_observe_channels (TpBaseClient *client,
&error);
if (tpl_chan == NULL)
{
- DEBUG ("%s", error->message);
+ DEBUG ("%s: %s", path, error->message);
g_clear_error (&error);
+ observing_ctx->chan_n--;
continue;
}
PATH_DEBUG (tpl_chan, "Starting preparation for TplChannel instance %p",
@@ -179,7 +185,27 @@ tpl_observer_observe_channels (TpBaseClient *client,
observing_ctx);
}
- tp_observe_channels_context_delay (context);
+ /* Arguably we shouldn't claim to have accepted the channels if an error
+ * occurred above? */
+ if (!observing_context_try_to_return (observing_ctx))
+ tp_observe_channels_context_delay (context);
+}
+
+static gboolean
+observing_context_try_to_return (ObservingContext *observing_ctx)
+{
+ if (observing_ctx->chan_n == 0)
+ {
+ DEBUG ("Returning from observe channels");
+ tp_observe_channels_context_accept (observing_ctx->ctx);
+ g_object_unref (observing_ctx->ctx);
+ g_slice_free (ObservingContext, observing_ctx);
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
}
static gboolean
@@ -224,13 +250,7 @@ got_tpl_channel_text_ready_cb (GObject *obj,
tp_proxy_get_object_path (obj));
observing_ctx->chan_n -= 1;
- if (observing_ctx->chan_n == 0)
- {
- DEBUG ("Returning from observe channels");
- tp_observe_channels_context_accept (observing_ctx->ctx);
- g_object_unref (observing_ctx->ctx);
- g_slice_free (ObservingContext, observing_ctx);
- }
+ observing_context_try_to_return (observing_ctx);
}