summaryrefslogtreecommitdiffstats
path: root/binding
diff options
context:
space:
mode:
authorRaquel Medina <raquel.medina@konsulko.com>2020-07-10 10:20:44 +0200
committerRaquel Medina <raquel.medina@konsulko.com>2020-07-13 13:01:37 +0200
commit542f2a95de3f08b22969d1f4899aa343da5e44ae (patch)
tree7dd56d80b4e9b4698fb55adfaefe7090b64f8224 /binding
parentd542c5ce356117a96907763c963128208105f947 (diff)
distinguish between no controller and no bluez service
The initialization sequence for dbus services is not fixed, and some races have been observed between blutoothd and agl-service-bluetooth when running on qemu: sometimes Bluetooth-Manager can be ready before org.bluez and this results in reporting no adapter, even though it's not accurate. Also, although this issue has been seen only using qemu, the race is there and it could also manifest in other platforms with a bluetooth controller attached. This patch simply provides the logic to discern between 'no org.bluez service found' and 'no bluetooth controller present': - in the case of no org.bluez service detected, an error is returned to allow for retries, - in the case of no controller present, no error is returned and agl-service-bluetooth completes the initialization. Bug-AGL: SPEC-3301 Signed-off-by: Raquel Medina <raquel.medina@konsulko.com> Change-Id: I4868803bcfbd36fb65028cea5c997c4f174675a0
Diffstat (limited to 'binding')
-rw-r--r--binding/bluetooth-api.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/binding/bluetooth-api.c b/binding/bluetooth-api.c
index 2309ef6..24ff11c 100644
--- a/binding/bluetooth-api.c
+++ b/binding/bluetooth-api.c
@@ -531,6 +531,7 @@ static int bluetooth_get_adapters_count(struct init_data *id)
AFB_INFO("object_properties for adapters count error: %s",
error->message);
g_clear_error(&error);
+ count = -EIO;
} else {
json_object_object_get_ex(jresp, "adapters", &jobj);
count = json_object_array_length(jobj);
@@ -648,9 +649,12 @@ static gpointer bluetooth_func(gpointer ptr)
rc = bluetooth_register_agent(id);
if (rc) {
AFB_ERROR("bluetooth_register_agent() failed");
- goto err_no_agent;
+ goto err_no_service;
}
}
+ else if (rc < 0) {
+ goto err_no_service;
+ }
else {
//fake it
AFB_INFO("No adapter present, completed initialization");
@@ -671,7 +675,7 @@ static gpointer bluetooth_func(gpointer ptr)
return NULL;
-err_no_agent:
+err_no_service:
bluetooth_cleanup(ns);
err_no_ns: