Skip to contentSkip to conversation

core: Do not change service state in btd_service_connect if it fails

PATCH Applied Luiz Augusto von Dentz 2 participants 2 messages Nov 14, 2013 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 core: Do not change service state in btd_service_connect if it fails

From: Luiz Augusto von Dentz <[email protected]>

If .connect fails and the service state changes it may re-enter connect_next, inverting the order and messing up the error of each connect request.

---
 src/service.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
src/service.c +3 -5
index 52a8291..7a480d6 100644
@@ -198,18 +198,16 @@ int btd_service_connect(struct btd_service *service)
 		return -EBUSY;
 	}
 
-	change_state(service, BTD_SERVICE_STATE_CONNECTING, 0);
-
 	err = profile->connect(service);
-	if (err == 0)
+	if (err == 0) {
+		change_state(service, BTD_SERVICE_STATE_CONNECTING, 0);
 		return 0;
+	}
 
 	ba2str(device_get_address(service->device), addr);
 	error("%s profile connect failed for %s: %s", profile->name, addr,
 								strerror(-err));
 
-	btd_service_connecting_complete(service, err);
-
 	return err;
 }
 
Signature · 1 line
1.8.3.1
#1 lore raw

Hi Luiz,

Quoted 6 lines · Luiz Augusto von Dentz

If .connect fails and the service state changes it may re-enter connect_next, inverting the order and messing up the error of each connect request.

---
 src/service.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Applied. Thanks.

Johan