diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2015-11-19 13:36:20 +0200 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2015-11-23 19:35:09 +0200 |
commit | 09be1b9b89fada2f6183b1a0acca62bd6832c70a (patch) | |
tree | f7aaf191d52e9d7508c0cdc5e27d006aabee3746 | |
parent | 941ff11632e32521622c2c3668eddb0b996b82ff (diff) | |
download | bluez-09be1b9b89fada2f6183b1a0acca62bd6832c70a.tar.gz |
core: Fix replying with an error for connected profile
If the profile(s) is already connected don't reply with an error, if the
profile is in fact connecting already just wait until it completes.
-rw-r--r-- | src/device.c | 8 | ||||
-rw-r--r-- | src/service.c | 1 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/device.c b/src/device.c index e76b8bb0a..902191410 100644 --- a/src/device.c +++ b/src/device.c @@ -1477,7 +1477,8 @@ static int connect_next(struct btd_device *dev) while (dev->pending) { service = dev->pending->data; - if (btd_service_connect(service) == 0) + err = btd_service_connect(service); + if (!err) return 0; dev->pending = g_slist_delete_link(dev->pending, dev->pending); @@ -1732,8 +1733,11 @@ static DBusMessage *connect_profiles(struct btd_device *dev, uint8_t bdaddr_type } err = connect_next(dev); - if (err < 0) + if (err < 0) { + if (err == -EALREADY) + return dbus_message_new_method_return(msg); return btd_error_failed(msg, strerror(-err)); + } dev->connect = dbus_message_ref(msg); diff --git a/src/service.c b/src/service.c index 3d07744e2..f7912f57a 100644 --- a/src/service.c +++ b/src/service.c @@ -228,6 +228,7 @@ int btd_service_connect(struct btd_service *service) case BTD_SERVICE_STATE_DISCONNECTED: break; case BTD_SERVICE_STATE_CONNECTING: + return 0; case BTD_SERVICE_STATE_CONNECTED: return -EALREADY; case BTD_SERVICE_STATE_DISCONNECTING: |