diff options
| author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2015-04-08 13:32:22 +0300 |
|---|---|---|
| committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2016-08-11 12:29:31 +0100 |
| commit | 5682b5f5cb43ba1bb89280f1be53889d707d3c43 (patch) | |
| tree | f672f1d133bfaee4dac2f43e0e74d5ea6ed9dbbc | |
| parent | d4cf4a4f4b7fc2886663563d8adcf2a81c6f0fc9 (diff) | |
| download | bluez-5682b5f5cb43ba1bb89280f1be53889d707d3c43.tar.gz | |
policy: Mark reconnect services
This make use of btd_service_reconnect to set reconnecting flag of
services.
| -rw-r--r-- | plugins/policy.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/plugins/policy.c b/plugins/policy.c index 80f1732d8..5a289101d 100644 --- a/plugins/policy.c +++ b/plugins/policy.c @@ -493,6 +493,25 @@ static void target_cb(struct btd_service *service, } } +static void mark_service(void *data, void *user_data) +{ + struct btd_service *service = data; + bool value = GPOINTER_TO_UINT(user_data); + + btd_service_reconnect(service, value); +} + +static void reconnect_set_active(struct reconnect_data *reconnect, bool value) +{ + if (reconnect->active == value) + return; + + reconnect->active = value; + + g_slist_foreach(reconnect->services, mark_service, + GUINT_TO_POINTER(value)); +} + static void reconnect_reset(struct reconnect_data *reconnect) { reconnect->attempt = 0; @@ -501,6 +520,8 @@ static void reconnect_reset(struct reconnect_data *reconnect) g_source_remove(reconnect->timer); reconnect->timer = 0; } + + reconnect_set_active(reconnect, false); } static bool reconnect_match(const char *uuid) @@ -643,7 +664,6 @@ static void service_cb(struct btd_service *service, */ reconnect = reconnect_add(service); - reconnect->active = false; reconnect_reset(reconnect); /* @@ -675,9 +695,6 @@ static gboolean reconnect_timeout(gpointer data) return FALSE; } - reconnect->active = true; - reconnect->attempt++; - return FALSE; } @@ -688,12 +705,14 @@ static void reconnect_set_timer(struct reconnect_data *reconnect) reconnect->attempt++; if (reconnect->attempt < reconnect_intervals_len) - timeout = reconnect_intervals[reconnect->attempt]; + timeout = reconnect_intervals[reconnect->attempt++]; DBG("%d seconds", timeout); reconnect->timer = g_timeout_add_seconds(timeout, reconnect_timeout, reconnect); + + reconnect_set_active(reconnect, true); } static void disconnect_cb(struct btd_device *dev, uint8_t reason) @@ -728,8 +747,6 @@ static void conn_fail_cb(struct btd_device *dev, uint8_t status) if (!reconnect->active) return; - reconnect->active = false; - /* Give up if we were powered off */ if (status == MGMT_STATUS_NOT_POWERED) { reconnect_reset(reconnect); |
