diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-01-17 16:35:48 +0100 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-05-12 12:30:41 +0200 |
commit | 15d953c08e40baa252e31b07d5c61565c841a3e3 (patch) | |
tree | ca68a3c2f2cbf5ec06f4238228ef967d5615292e /telepathy-glib/proxy.c | |
parent | 3d9c255172a9641fd7df32a71fbeeac0642ee08d (diff) | |
download | telepathy-glib-15d953c08e40baa252e31b07d5c61565c841a3e3.tar.gz |
retry preparing failed dep, if possible
Diffstat (limited to 'telepathy-glib/proxy.c')
-rw-r--r-- | telepathy-glib/proxy.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/telepathy-glib/proxy.c b/telepathy-glib/proxy.c index f315abb77..28230d29f 100644 --- a/telepathy-glib/proxy.c +++ b/telepathy-glib/proxy.c @@ -1627,12 +1627,16 @@ check_feature_interfaces (TpProxy *self, } /* Returns %TRUE if all the deps of @name are ready + * @can_retry: if %TRUE dependencies which have failed but have + * TpProxyFeature.can_retry won't be considered as having failed so we'll + * still have a change to retry preparing those. * @failed: (out): %TRUE if one of @name's dep can't be prepared and so * @name can't be either */ static gboolean check_depends_ready (TpProxy *self, GQuark name, + gboolean can_retry, gboolean *failed) { const TpProxyFeature *feature = tp_proxy_subclass_get_feature ( @@ -1649,21 +1653,35 @@ check_depends_ready (TpProxy *self, for (i = 0; feature->depends_on[i] != 0; i++) { GQuark dep = feature->depends_on[i]; + const TpProxyFeature *dep_feature = tp_proxy_subclass_get_feature ( + G_OBJECT_TYPE (self), dep); FeatureState dep_state; dep_state = tp_proxy_get_feature_state (self, dep); switch (dep_state) { case FEATURE_STATE_INVALID: - case FEATURE_STATE_FAILED: - DEBUG ("Can't prepare %s, one is dep %s: %s", - g_quark_to_string (name), - dep_state == FEATURE_STATE_INVALID ? "is invalid": "failed", - g_quark_to_string (dep)); + DEBUG ("Can't prepare %s, one dep is invalid: %s", + g_quark_to_string (name), g_quark_to_string (dep)); *failed = TRUE; return FALSE; + case FEATURE_STATE_FAILED: + if (!can_retry || !dep_feature->can_retry) + { + DEBUG ("Can't prepare %s, one dep failed: %s", + g_quark_to_string (name), g_quark_to_string (dep)); + + *failed = TRUE; + return FALSE; + } + + DEBUG ("retry preparing dep: %s", g_quark_to_string (dep)); + tp_proxy_set_feature_state (self, dep, FEATURE_STATE_WANTED); + ready = FALSE; + break; + case FEATURE_STATE_UNWANTED: case FEATURE_STATE_WANTED: case FEATURE_STATE_TRYING: @@ -1789,8 +1807,11 @@ tp_proxy_prepare_async (gpointer self, { gboolean failed; - /* Check deps */ - if (!check_depends_ready (self, features[i], &failed)) + /* Check deps. We only offer there the chance to retry a previously + * failed dependency. Doing it in tp_proxy_poll_features() could + * result in an infinite loop if we'd depends on 2 features which + * are constantly failing. */ + if (!check_depends_ready (self, features[i], TRUE, &failed)) { if (failed) { @@ -1962,7 +1983,7 @@ request_is_complete (TpProxy *self, continue; } - if (check_depends_ready (self, feature, &failed)) + if (check_depends_ready (self, feature, FALSE, &failed)) { /* We can prepare it now */ DEBUG ("%p: calling callback for %s", self, |