summaryrefslogtreecommitdiff
path: root/plugins/policy.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2013-07-11 12:40:54 +0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2013-07-12 15:05:50 +0300
commit48e31375652d4ebaa2be223196781a0b0ae00b79 (patch)
treecc2515ad902155bd8a956ee8bf695d257ccaf8eb /plugins/policy.c
parent7662d49f57a5aab7990cea36b6f2d3eab7663d6a (diff)
downloadbluez-48e31375652d4ebaa2be223196781a0b0ae00b79.tar.gz
plugins/policy: Limit the number of retries to source profile
The policy should only retry a limit number of times.
Diffstat (limited to 'plugins/policy.c')
-rw-r--r--plugins/policy.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/policy.c b/plugins/policy.c
index c5873734c..02150b083 100644
--- a/plugins/policy.c
+++ b/plugins/policy.c
@@ -42,6 +42,7 @@
#define CONTROL_CONNECT_TIMEOUT 2
#define SOURCE_RETRY_TIMEOUT 2
#define SINK_RETRY_TIMEOUT SOURCE_RETRY_TIMEOUT
+#define SOURCE_RETRIES 1
static unsigned int service_id = 0;
static GSList *devices = NULL;
@@ -50,6 +51,7 @@ struct policy_data {
struct btd_device *dev;
guint source_timer;
+ uint8_t source_retries;
guint sink_timer;
guint ct_timer;
guint tg_timer;
@@ -258,6 +260,7 @@ static gboolean policy_connect_source(gpointer user_data)
struct btd_service *service;
data->source_timer = 0;
+ data->source_retries++;
service = btd_device_get_service(data->dev, A2DP_SOURCE_UUID);
if (service != NULL)
@@ -297,7 +300,10 @@ static void source_cb(struct btd_service *service,
int err = btd_service_get_error(service);
if (err == -EAGAIN) {
- policy_set_source_timer(data);
+ if (data->source_retries < SOURCE_RETRIES)
+ policy_set_source_timer(data);
+ else
+ data->source_retries = 0;
break;
} else if (data->source_timer > 0) {
g_source_remove(data->source_timer);