From 5d143ba35e1af7cc090f1c8c53fa4957efd258e2 Mon Sep 17 00:00:00 2001 From: Mikel Astiz Date: Tue, 4 Sep 2012 13:15:55 +0200 Subject: [PATCH] audio: Fix gateway in connecting state forever 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 file changed, 10 insertions(+), 3 deletions(-) diff --git a/audio/gateway.c b/audio/gateway.c index 77a8cb019..860303884 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, -- 2.47.3