Allow user to initiate connection if there are multiple devices
of the same technology type available (like having multiple wifi
cards).
---
Hi,

This is a resend of the patch I sent two months ago.

I have been testing connman with two wifi cards and it is very
annoying that if the connection attempt takes very long time,
I cannot connect using the other wifi card because the first
one is still connecting. So I finally cooked this patch that helps
with this issue.

Cheers,
Jukka

 src/service.c |   33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/service.c b/src/service.c
index fdd59d5..fbaa326 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3534,6 +3534,29 @@ static connman_bool_t get_reconnect_state(struct 
connman_service *service)
        return __connman_device_get_reconnect(device);
 }
 
+static connman_bool_t is_interface_available(struct connman_service *service,
+                                       struct connman_service *other_service)
+{
+       unsigned int index = 0, other_index = 0;
+
+       if (service->ipconfig_ipv4 != NULL)
+               index = __connman_ipconfig_get_index(service->ipconfig_ipv4);
+       else if (service->ipconfig_ipv6 != NULL)
+               index = __connman_ipconfig_get_index(service->ipconfig_ipv6);
+
+       if (other_service->ipconfig_ipv4 != NULL)
+               other_index = __connman_ipconfig_get_index(
+                                               other_service->ipconfig_ipv4);
+       else if (other_service->ipconfig_ipv6 != NULL)
+               other_index = __connman_ipconfig_get_index(
+                                               other_service->ipconfig_ipv6);
+
+       if (index > 0 && other_index != index)
+               return TRUE;
+
+       return FALSE;
+}
+
 static DBusMessage *connect_service(DBusConnection *conn,
                                        DBusMessage *msg, void *user_data)
 {
@@ -3551,7 +3574,15 @@ static DBusMessage *connect_service(DBusConnection *conn,
        while (g_sequence_iter_is_end(iter) == FALSE) {
                struct connman_service *temp = g_sequence_get(iter);
 
-               if (service->type == temp->type && is_connecting(temp) == TRUE)
+               /*
+                * We should allow connection if there are available
+                * interfaces for a given technology type (like having
+                * more than one wifi card).
+                */
+               if (service->type == temp->type &&
+                               is_connecting(temp) == TRUE &&
+                               is_interface_available(service,
+                                                       temp) == FALSE)
                        return __connman_error_in_progress(msg);
 
                iter = g_sequence_iter_next(iter);
-- 
1.7.9.5

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

Reply via email to