service: Do not try to connect to service that cannot create connection
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Tue, 7 Aug 2012 14:08:39 +0000 (17:08 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 8 Aug 2012 12:57:31 +0000 (15:57 +0300)
Check if the service IPv4/6 ipconfig is turned OFF, in this
case do not try to connect to that service because it will
not succeed.

Fixes BMC#25587

src/service.c

index dfe1752..abd429c 100644 (file)
@@ -3235,6 +3235,16 @@ static DBusMessage *clear_property(DBusConnection *conn,
        return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
 
+static connman_bool_t is_ipconfig_usable(struct connman_service *service)
+{
+       if (__connman_ipconfig_is_usable(service->ipconfig_ipv4) == FALSE &&
+                       __connman_ipconfig_is_usable(service->ipconfig_ipv6)
+                                                               == FALSE)
+               return FALSE;
+
+       return TRUE;
+}
+
 static connman_bool_t is_ignore(struct connman_service *service)
 {
        if (service->autoconnect == FALSE)
@@ -3249,6 +3259,9 @@ static connman_bool_t is_ignore(struct connman_service *service)
        if (service->state == CONNMAN_SERVICE_STATE_FAILURE)
                return TRUE;
 
+       if (is_ipconfig_usable(service) == FALSE)
+               return TRUE;
+
        return FALSE;
 }
 
@@ -5447,6 +5460,9 @@ int __connman_service_connect(struct connman_service *service)
        case CONNMAN_SERVICE_TYPE_GADGET:
                return -EINVAL;
        default:
+               if (is_ipconfig_usable(service) == FALSE)
+                       return -ENOLINK;
+
                err = service_connect(service);
        }