technology: Offlinemode could not be disabled if no technology was powered
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Fri, 7 Jun 2013 12:15:29 +0000 (15:15 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Mon, 10 Jun 2013 06:48:54 +0000 (09:48 +0300)
If all the technologies were powered off, then offline mode could
not be disabled.

Fixes BMC#26018

src/technology.c

index f210859..632f716 100644 (file)
@@ -1472,7 +1472,7 @@ int __connman_technology_disabled(enum connman_service_type type)
 int __connman_technology_set_offlinemode(connman_bool_t offlinemode)
 {
        GSList *list;
-       int err = -EINVAL;
+       int err = -EINVAL, enabled_tech_count = 0;
 
        if (global_offlinemode == offlinemode)
                return 0;
@@ -1496,12 +1496,16 @@ int __connman_technology_set_offlinemode(connman_bool_t offlinemode)
 
                if (offlinemode)
                        err = technology_disable(technology);
-
-               if (!offlinemode && technology->enable_persistent)
-                       err = technology_enable(technology);
+               else {
+                       if (technology->enable_persistent) {
+                               err = technology_enable(technology);
+                               enabled_tech_count++;
+                       }
+               }
        }
 
-       if (err == 0 || err == -EINPROGRESS || err == -EALREADY) {
+       if (err == 0 || err == -EINPROGRESS || err == -EALREADY ||
+                       (err == -EINVAL && enabled_tech_count == 0)) {
                connman_technology_save_offlinemode();
                __connman_notifier_offlinemode(offlinemode);
        } else