When connected via D-Bus, iterate only over the beginning of the list
where the services are either connected or connecting. If the interface
is not available, disconnect the other service(s) which use the
interface. Once all disconnections are progressing, bail out if any
of them was asynchronous. Do not force the service to idle, as it will
not be possible to do an anychronous disconnect otherwise.
---
 src/service.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/service.c b/src/service.c
index b215bfd..cfc9cd1 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3953,8 +3953,8 @@ static DBusMessage *connect_service(DBusConnection *conn,
                                        DBusMessage *msg, void *user_data)
 {
        struct connman_service *service = user_data;
+       int err = 0;
        GList *list;
-       int err;
 
        DBG("service %p", service);
 
@@ -3969,15 +3969,19 @@ static DBusMessage *connect_service(DBusConnection 
*conn,
                 * interfaces for a given technology type (like having
                 * more than one wifi card).
                 */
-               if (service->type == temp->type &&
-                               is_connecting(temp) &&
-                               !is_interface_available(service, temp)) {
-
-                       __connman_service_disconnect(temp);
-                       set_idle(temp);
+               if (!is_connecting(temp) && !is_connected(temp))
                        break;
+
+               if (service->type != temp->type)
+                       continue;
+
+               if(!is_interface_available(service, temp)) {
+                       if (__connman_service_disconnect(temp) == -EINPROGRESS)
+                               err = -EINPROGRESS;
                }
        }
+       if (err == -EINPROGRESS)
+               return __connman_error_in_progress(msg);
 
        service->ignore = false;
 
-- 
1.8.5.3

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to