Modify -f option of app launcher 32/302432/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 6 Dec 2023 10:17:42 +0000 (19:17 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 6 Dec 2023 10:17:42 +0000 (19:17 +0900)
If the option is 'fast launch', the app launcher does not set the recv
timeout. If initialization of launchpad takes a long time, duplicate execution
occurs. This patch is applied to prevent this.

Change-Id: If198da87976656d70077a73aeeb36c0f25a803c6
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/aul_sock.h
src/aul_sock.cc
tool/app_launcher/app_launcher.c

index 5dc8e89..d0156a9 100644 (file)
@@ -143,6 +143,11 @@ int aul_sock_send_result_v2(int fd, int res, bool do_close);
  */
 int aul_sock_recv_reply_pkt_v2(int fd, app_pkt_t **pkt, bool do_close);
 
+/**
+ * This API is only for Appfw internally.
+ */
+int aul_sock_create_launchpad_client_without_timeout(const char *pad_type, uid_t uid);
+
 #ifdef __cplusplus
 }
 #endif
index c1d6e10..3b687ce 100644 (file)
@@ -601,6 +601,24 @@ extern "C" API int aul_sock_recv_reply_sock_fd(int fd, int (*ret_fd)[2],
   return ret;
 }
 
+extern "C" API int aul_sock_create_launchpad_client_without_timeout(
+    const char* pad_type, uid_t uid) {
+  int fd = -1;
+  try {
+    ClientSocket client;
+    std::string endpoint = "/run/aul/daemons/" + std::to_string(uid) + "/" +
+      std::string(pad_type);
+    client.Connect(endpoint);
+    fd = client.RemoveFd();
+    aul_sock_set_sock_option(fd, 0);
+  } catch (const Exception& e) {
+    _E("Exception occurs. error(%d)", e.GetErrorCode());
+    return e.GetErrorCode();
+  }
+
+  return fd;
+}
+
 extern "C" API int aul_sock_create_launchpad_client(const char* pad_type,
     uid_t uid) {
   int fd = -1;
index 820b88d..7001f1f 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "aul.h"
 #include "aul_svc.h"
+#include "aul_sock.h"
 #include "launch.h"
 
 #define LAUNCHPAD_PROCESS_POOL_SOCK ".launchpad-process-pool-sock"
@@ -600,6 +601,8 @@ end:
 
 static int __cmd_fast_start_run(struct launch_arg *arg)
 {
+       int fd;
+
        if (!access(PATH_AMD_READY, F_OK))
                return __cmd_start_run(arg);
 
@@ -608,8 +611,14 @@ static int __cmd_fast_start_run(struct launch_arg *arg)
                return -1;
        }
 
-       arg->pid = app_send_cmd_to_launchpad(LAUNCHPAD_PROCESS_POOL_SOCK,
-                       arg->uid, 0, arg->b);
+       fd = aul_sock_create_launchpad_client_without_timeout(
+                       LAUNCHPAD_PROCESS_POOL_SOCK, arg->uid);
+       if (fd < 0) {
+               printf("Failed to create client socket. error: %d\n", fd);
+               return -1;
+       }
+
+       arg->pid = aul_sock_send_bundle_with_fd(fd, 0, arg->b, AUL_SOCK_NONE);
        if (arg->pid <= 0) {
                printf("... launch failed\n");
                return -1;