Thread (4 messages) flat view 4 messages, 2 authors, 2012-09-04
STALE5129d

[PATCH v0 2/3] audio: Fix gateway in connecting state forever

From: Mikel Astiz <hidden>
Date: 2012-09-04 11:15:55
Subsystem: the rest · Maintainer: Linus Torvalds

From: Mikel Astiz <redacted>

If bt_search_service() fails the state should be left unchanged.
Otherwise the gateway state is set forever to GATEWAY_STATE_CONNECTING.

This issue can be easily reproduced if a connection attempt is done
very soon after startup.
---
 audio/gateway.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/audio/gateway.c b/audio/gateway.c
index 77a8cb0..8603038 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -526,11 +526,18 @@ fail:
 static int get_records(struct audio_device *device)
 {
 	uuid_t uuid;
+	int err;
 
-	change_state(device, GATEWAY_STATE_CONNECTING);
 	sdp_uuid16_create(&uuid, HANDSFREE_AGW_SVCLASS_ID);
-	return bt_search_service(&device->src, &device->dst, &uuid,
-				get_record_cb, device, NULL);
+
+	err = bt_search_service(&device->src, &device->dst, &uuid,
+						get_record_cb, device, NULL);
+	if (err < 0)
+		return err;
+
+	change_state(device, GATEWAY_STATE_CONNECTING);
+
+	return 0;
 }
 
 static DBusMessage *ag_connect(DBusConnection *conn, DBusMessage *msg,
-- 
1.7.7.6
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help