Fix a bug about handling OOM 26/245726/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 14 Oct 2020 23:00:21 +0000 (08:00 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 14 Oct 2020 23:05:09 +0000 (08:05 +0900)
When system is out of memory and the low memory status is true,
launchpad-process-pool always tries to kill last running slot.
Even if there is no running slot, launchpad-process-pool tries that.
Because, the memory status is true. In that time, launchpad-process-pool
is deadlock state.
After this patch is applied, launchpad-process-pool tries to kill
all running slots when system is OOM. If system is not OOM,
launchpad-process-pool stops killing slots.

Change-Id: I5ff858e20e948407252f603894ffb3edf7d64b12
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/launchpad-process-pool/src/launchpad.c

index c506541..d1585f1 100644 (file)
@@ -530,7 +530,7 @@ static candidate_process_context_t *__get_running_slot(bool is_hydra)
        return NULL;
 }
 
-static void __pause_last_running_slot(bool is_hydra)
+static void __pause_all_running_slots(bool is_hydra)
 {
        candidate_process_context_t *cpc = NULL;
        GList *iter;
@@ -538,16 +538,14 @@ static void __pause_last_running_slot(bool is_hydra)
        iter = g_list_last(candidate_slot_list);
        while (iter) {
                cpc = (candidate_process_context_t *)iter->data;
-               if (cpc->is_hydra == is_hydra && cpc->pid != CANDIDATE_NONE)
-                       break;
+               if (cpc->is_hydra == is_hydra && cpc->pid != CANDIDATE_NONE) {
+                       __update_slot_state(cpc, METHOD_OUT_OF_MEMORY, true);
+                       if (!_memory_monitor_is_low_memory())
+                               return;
+               }
 
                iter = g_list_previous(iter);
        }
-
-       if (!cpc)
-               return;
-
-       __update_slot_state(cpc, METHOD_OUT_OF_MEMORY, true);
 }
 
 static void __resume_all_slots(void)
@@ -3023,14 +3021,7 @@ static int __memory_monitor_cb(bool low_memory, void *user_data)
 
                candidate_slot_list = g_list_sort(candidate_slot_list,
                                __compare_slot);
-
-               do {
-                       __pause_last_running_slot(false);
-
-                       cpc = __get_running_slot(false);
-                       if (!cpc)
-                               break;
-               } while (__is_low_memory());
+               __pause_all_running_slots(false);
        } else {
                __resume_all_slots();
        }