Add logs for debugging loader creation 01/289401/1
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 7 Mar 2023 05:57:08 +0000 (05:57 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 7 Mar 2023 05:57:08 +0000 (05:57 +0000)
To debug loader creation, new logs are added.

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

index 9a7b293..ed0a39a 100644 (file)
@@ -811,7 +811,8 @@ static gboolean __handle_deactivate_event(gpointer user_data) {
 
   cpc = (candidate_process_context_t*)user_data;
   __update_slot_state(cpc, launchpad::LoaderMethod::Ttl, false);
-  _D("Deactivate event: type(%d)", cpc->type);
+  _D("Deactivate event: type(%d), loader_name(%s)",
+      cpc->type, cpc->loader_name);
 
   return G_SOURCE_REMOVE;
 }
@@ -969,6 +970,8 @@ static gboolean __handle_timeout_event(gpointer user_data) {
   cpc = (candidate_process_context_t*)user_data;
   cpc->timer = 0;
 
+  _W("type(%d), loader_name(%s), state(%d)",
+      cpc->type, cpc->loader_name, cpc->state);
   if (cpc->pid != CANDIDATE_NONE) {
     _W("Candidate(%d) process(%d) is running", cpc->type, cpc->pid);
     return G_SOURCE_REMOVE;
@@ -980,12 +983,22 @@ static gboolean __handle_timeout_event(gpointer user_data) {
 }
 
 static void __set_timer(candidate_process_context_t* cpc) {
-  if (cpc == nullptr || cpc->timer > 0)
+  if (cpc == nullptr || cpc->timer > 0) {
+    _E("Invalid parameter");
     return;
+  }
 
-  if ((cpc->detection_method & static_cast<int>(launchpad::LoaderMethod::Timeout)) &&
+  _W("type(%d), loader_name(%s), state(%d)",
+      cpc->type, cpc->loader_name, cpc->state);
+  if ((cpc->detection_method &
+        static_cast<int>(launchpad::LoaderMethod::Timeout)) &&
       cpc->state == CANDIDATE_PROCESS_STATE_RUNNING) {
     cpc->timer = g_timeout_add(cpc->timeout_val, __handle_timeout_event, cpc);
+    if (cpc->timer == 0)
+      _E("g_timeout_add() is failed. %d:%s", cpc->type, cpc->loader_name);
+  } else {
+    _E("Skip adding timer. detection_method(%d), state(%d)",
+        cpc->detection_method, cpc->state);
   }
 }
 
@@ -1006,7 +1019,7 @@ static void __dispose_candidate_process(candidate_process_context_t* cpc) {
   if (!cpc)
     return;
 
-  _D("Dispose candidate process %d", cpc->type);
+  _D("Dispose candidate process %d:%s", cpc->type, cpc->loader_name);
   if (cpc->pid > 0) {
     _D("kill process %d", cpc->pid);
     __kill_process(cpc->pid);
@@ -1030,7 +1043,7 @@ static void __dispose_hydra_process(candidate_process_context_t* cpc) {
 
   __dispose_candidate_process(cpc);
 
-  _D("Dispose hydra process %d", cpc->type);
+  _D("Dispose hydra process %d:%s", cpc->type, cpc->loader_name);
   if (cpc->hydra_pid > 0) {
     _D("kill process %d", cpc->hydra_pid);
     __kill_process(cpc->hydra_pid);
@@ -1055,7 +1068,7 @@ static int __send_launchpad_loader(candidate_process_context_t* cpc,
     return -1;
 
   __candidate_process_real_launch(cpc->send_fd, pkt);
-  SECURE_LOGD("Request to candidate process, pid: %d, bin path: %s", cpc->pid,
+  _W("Request to candidate process, pid: %d, bin path: %s", cpc->pid,
               app_path);
 
   pid = cpc->pid;
@@ -2129,6 +2142,8 @@ static void __update_slot(int type, bool app_exists) {
     return;
 
   cpc->app_exists = app_exists;
+  _W("type(%d), loader_name(%s), app_check(%d), app_exists(%d)",
+      cpc->type, cpc->loader_name, cpc->app_check, cpc->app_exists);
   if (cpc->app_check && !cpc->app_exists) {
     if (cpc->pid > 0)
       __dispose_candidate_process(cpc);
@@ -2192,6 +2207,8 @@ static int __dispatch_cmd_update_app_type(bundle* b) {
 }
 
 static void __deactivate_slot(candidate_process_context_t* cpc) {
+  _W("type(%d), loader_name(%s), state(%d)",
+      cpc->type, cpc->loader_name, cpc->state);
   if (cpc->state == CANDIDATE_PROCESS_STATE_PAUSED)
     return;
 
@@ -2203,6 +2220,8 @@ static void __deactivate_slot(candidate_process_context_t* cpc) {
 }
 
 static void __activate_slot(candidate_process_context_t* cpc) {
+  _W("type(%d), loader_name(%s), state(%d)",
+      cpc->type, cpc->loader_name, cpc->state);
   if (cpc->state == CANDIDATE_PROCESS_STATE_RUNNING)
     return;
 
@@ -2213,16 +2232,19 @@ static void __activate_slot(candidate_process_context_t* cpc) {
   if ((cpc->app_check && !cpc->app_exists) || cpc->pid > CANDIDATE_NONE)
     return;
 
-  if (cpc->detection_method & static_cast<int>(launchpad::LoaderMethod::Timeout))
+  if (cpc->detection_method &
+      static_cast<int>(launchpad::LoaderMethod::Timeout))
     __set_timer(cpc);
 }
 
 static void __update_slot_state(candidate_process_context_t* cpc,
-                                launchpad::LoaderMethod method,
-                                bool force) {
+    launchpad::LoaderMethod method, bool force) {
+  _W("type(%d), loader_name(%s), state(%d), method(%d), force(%d)",
+      cpc->type, cpc->loader_name, cpc->state, static_cast<int>(method), force);
   switch (method) {
     case launchpad::LoaderMethod::OutOfMemory:
-      if ((force || cpc->deactivation_method & static_cast<int>(method)) && __is_low_memory()) {
+      if ((force || cpc->deactivation_method & static_cast<int>(method)) &&
+          __is_low_memory()) {
         _W("Low memory, deactivate slot %d", cpc->type);
         __deactivate_slot(cpc);
       } else {