swap: FIX Do not setup swap after resourced restart 87/199087/1 accepted/tizen/unified/20190213.071904 submit/tizen/20190212.103739
authorKonrad Kuchciak <k.kuchciak@samsung.com>
Fri, 1 Feb 2019 12:13:37 +0000 (13:13 +0100)
committerKonrad Kuchciak <k.kuchciak@samsung.com>
Fri, 1 Feb 2019 12:15:46 +0000 (13:15 +0100)
Change-Id: I1aa3bdf1ab5b2781238b3830389dccf7599e081a
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
src/swap/swap.c

index 315cc1a..0418686 100644 (file)
@@ -1014,11 +1014,6 @@ static int swap_init(void)
        if (!arg_swap_enable)
                return -ENODEV;
 
-       if (resourced_restarted()) {
-               _I("Assuming swap is already set up. To reconfigure, reboot the device.");
-               return 0;
-       }
-
        gslist_for_each_safe(swap_module, iter, next, swaps) {
                swaps = (struct swap_module_ops *)iter->data;
                if (!CHECK_BIT(arg_swap_type, swaps->type)) {
@@ -1157,9 +1152,14 @@ static int resourced_swap_init(void *data)
        if (ret != RESOURCED_ERROR_NONE)
                return ret;
 
+       if (!resourced_restarted()) {
+               register_notifier(RESOURCED_NOTIFIER_BOOTING_DONE, swap_activate_handler);
+       } else {
+               _I("Assuming swap is already set up. To reconfigure, reboot the device.");
+       }
+
        register_notifier(RESOURCED_NOTIFIER_SWAP_START, swap_start_handler);
        register_notifier(RESOURCED_NOTIFIER_SWAP_ACTIVATE, swap_activate_handler);
-       register_notifier(RESOURCED_NOTIFIER_BOOTING_DONE, swap_activate_handler);
        register_notifier(RESOURCED_NOTIFIER_SWAP_COMPACT, swap_compact_handler);
        register_notifier(RESOURCED_NOTIFIER_SWAP_UNSET_LIMIT, swap_cgroup_reset_limit);