service: Disconnect the connecting service when needed
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Mon, 25 Mar 2013 11:45:25 +0000 (13:45 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 27 Mar 2013 13:21:21 +0000 (15:21 +0200)
If we are trying to connect a service and there is another
service connecting, then we disconnect the pending service
and connect the new one.

Fixes BMC#25981

src/service.c

index 78e904f..469140a 100644 (file)
@@ -3789,8 +3789,18 @@ static DBusMessage *connect_service(DBusConnection *conn,
                if (service->type == temp->type &&
                                is_connecting(temp) == TRUE &&
                                is_interface_available(service,
-                                                       temp) == FALSE)
-                       return __connman_error_in_progress(msg);
+                                                       temp) == FALSE) {
+                       if (temp->pending != NULL)
+                               __connman_service_return_error(temp,
+                                                       ECONNABORTED,
+                                                       NULL);
+
+                       err = __connman_service_disconnect(temp);
+                       if (err < 0 && err != -EINPROGRESS)
+                               return __connman_error_in_progress(msg);
+                       else
+                               break;
+               }
 
                iter = g_sequence_iter_next(iter);
        }