From 2226f5c1880661e5c26ccd42cdc3a8547d8fe982 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 11 Nov 2019 09:47:51 +0900 Subject: [PATCH 01/16] Release version 0.10.0 Changes: - Refactor Launchpad Hydra Loader Change-Id: I93e611f010745e3efbe6f23f6428a75cf85b7596 Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 406742a..ae7f379 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.9.6 +Version: 0.10.0 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From ead9132d51e8ec67e818b478d4fb252dcb36c2a3 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 15 Nov 2019 11:24:32 +0900 Subject: [PATCH 02/16] Support prelink feature If the `_prelink_enable` is defined, launchpad-process-pool and launchpad-loader will be compiled without -pie and -fPIE option. Change-Id: I91c2743b781121b1862d4b567e875c0d4da62943 Signed-off-by: Hwankyu Jhun --- CMakeLists.txt | 18 ++++++++++++++++++ packaging/launchpad.spec | 11 +++++++++++ 2 files changed, 29 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e338b05..ad32426 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,8 +74,16 @@ SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} -fdata-sections -ffunction-secti SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} -D_FILE_OFFSET_BITS=64") SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} -Werror") +IF(_TIZEN_FEATURE_PRELINK) +MESSAGE(STATUS "[__PRELINK__] Enable") +SET(EXTRA_CFLAGS_pool "${EXTRA_CFLAGS_pool} ${EXTRA_CFLAGS_common}") +SET(EXTRA_CFLAGS_loader "${EXTRA_CFLAGS_loader} ${EXTRA_CFLAGS_common}") +ELSE(_TIZEN_FEATURE_PRELINK) +MESSAGE(STATUS "[__PRELINK__] Disable") SET(EXTRA_CFLAGS_pool "${EXTRA_CFLAGS_pool} ${EXTRA_CFLAGS_common} -fPIE") SET(EXTRA_CFLAGS_loader "${EXTRA_CFLAGS_loader} ${EXTRA_CFLAGS_common} -fPIE") +ENDIF(_TIZEN_FEATURE_PRELINK) + SET(EXTRA_CFLAGS_lib "${EXTRA_CFLAGS_lib} ${EXTRA_CFLAGS_common}") SET(EXTRA_CFLAGS_hydra "${EXTRA_CFLAGS_hydra} ${EXTRA_CFLAGS_common}") @@ -114,7 +122,13 @@ ADD_EXECUTABLE(${LAUNCHPAD_LOADER} ${${LAUNCHPAD_LOADER}_SOURCE_FILES}) # Since we cannot set LD_LIBRARY_PATH directly by security issue, we make the # dynamic linker looks in the CWD forcely. TARGET_LINK_LIBRARIES(${LAUNCHPAD_LOADER} "-ldl -Wl,-rpath,: -Wl,--disable-new-dtags") + +IF(_TIZEN_FEATURE_PRELINK) +TARGET_LINK_LIBRARIES(${LAUNCHPAD_LOADER} ${${this_target_loader}_LDFLAGS}) +ELSE(_TIZEN_FEATURE_PRELINK) TARGET_LINK_LIBRARIES(${LAUNCHPAD_LOADER} ${${this_target_loader}_LDFLAGS} "-pie") +ENDIF(_TIZEN_FEATURE_PRELINK) + SET_TARGET_PROPERTIES(${LAUNCHPAD_LOADER} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_loader}) SET_TARGET_PROPERTIES(${LAUNCHPAD_LOADER} PROPERTIES SKIP_BUILD_RPATH TRUE @@ -135,7 +149,11 @@ SET(${LAUNCHPAD_PROCESS_POOL}_SOURCE_FILES ) ADD_EXECUTABLE(${LAUNCHPAD_PROCESS_POOL} ${${LAUNCHPAD_PROCESS_POOL}_SOURCE_FILES}) +IF(_TIZEN_FEATURE_PRELINK) +TARGET_LINK_LIBRARIES(${LAUNCHPAD_PROCESS_POOL} ${${this_target_pool}_LDFLAGS} "-lm") +ELSE(_TIZEN_FEATURE_PRELINK) TARGET_LINK_LIBRARIES(${LAUNCHPAD_PROCESS_POOL} ${${this_target_pool}_LDFLAGS} "-pie -lm") +ENDIF(_TIZEN_FEATURE_PRELINK) SET_TARGET_PROPERTIES(${LAUNCHPAD_PROCESS_POOL} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_pool}) SET_TARGET_PROPERTIES(${LAUNCHPAD_PROCESS_POOL} PROPERTIES SKIP_BUILD_RPATH TRUE diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index ae7f379..89b88b4 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -44,6 +44,13 @@ Obsoletes: amd-mod-launchpad %define tizen_arch32 0 %endif + +%if "%{?_prelink_enable}" == "y" +%define tizen_feature_prelink 1 +%else +%define tizen_feature_prelink 0 +%endif + %description Launchpad for launching applications @@ -95,6 +102,9 @@ _TIZEN_FEATURE_LOADER_PRIORITY=ON %if 0%{?tizen_arch32} _TIZEN_FEATURE_SET_PERSONALITY_32=ON %endif +%if 0%{?tizen_feature_prelink} +_TIZEN_FEATURE_PRELINK=ON +%endif MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake -DVERSION=%{version} \ @@ -102,6 +112,7 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -D_TIZEN_FEATURE_PRIORITY_CHANGE:BOOL=${_TIZEN_FEATURE_PRIORITY_CHANGE} \ -D_TIZEN_FEATURE_LOADER_PRIORITY:BOOL=${_TIZEN_FEATURE_LOADER_PRIORITY} \ -D_TIZEN_FEATURE_SET_PERSONALITY_32:BOOL=${_TIZEN_FEATURE_SET_PERSONALITY_32} \ + -D_TIZEN_FEATURE_PRELINK:BOOL=${_TIZEN_FEATURE_PRELINK} \ . %__make %{?_smp_mflags} -- 2.7.4 From 42c0e226cfd1128a32100ea6b6fa999842607342 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 15 Nov 2019 12:22:57 +0900 Subject: [PATCH 03/16] Release version 0.10.1 Changes: - Support prelink feature Change-Id: I8c6c1b11f1e6541cd78a37b44b1818e25a52373f Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 89b88b4..0deb0e4 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.10.0 +Version: 0.10.1 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 464357174a33d96b8ded3c48080c083cc73e3f14 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 20 Dec 2019 10:17:04 +0900 Subject: [PATCH 04/16] Use monotonic time To measure launching time properly, we should use monotonic time. Requires: - https://review.tizen.org/gerrit/#/c/platform/core/appfw/aul-1/+/220595/ - https://review.tizen.org/gerrit/#/c/platform/core/appfw/amd/+/220598/ - https://review.tizen.org/gerrit/#/c/platform/core/appfw/launchpad/+/220600/ Change-Id: I3df67a01234fcd5cb54248bbfc0519d9564a08d6 Signed-off-by: Hwankyu Jhun --- inc/perf.h | 58 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/inc/perf.h b/inc/perf.h index 3bc169f..ca87d12 100644 --- a/inc/perf.h +++ b/inc/perf.h @@ -19,38 +19,38 @@ #ifdef PERF_ACTIVATE -#include -static struct timeval __g_base_time = { +#include + +static struct timespec __g_base_time = { .tv_sec = 0, - .tv_usec = 0 + .tv_nsec = 0 }; -#define INIT_PERF(kb) \ - do { \ - const char *tmp; \ - struct timeval tv; \ - tmp = bundle_get_val(kb, AUL_K_STARTTIME); \ - if (tmp != NULL) \ - sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec); \ - else \ - gettimeofday(&tv, NULL); \ - __g_base_time.tv_sec = tv.tv_sec; \ - __g_base_time.tv_usec = tv.tv_usec; \ - } while (0) - -#define PERF(fmt, arg...) \ - do { \ - struct timeval cur; \ - struct timeval res; \ - gettimeofday(&cur, NULL); \ - if (__g_base_time.tv_sec != 0) { \ - timersub(&cur, &__g_base_time, &res); \ - printf("%c[1;31m[%s,%d] %ld sec %ld msec "fmt \ - " %c[0m\n", 27, __func__, \ - __LINE__, res.tv_sec, \ - res.tv_usec/1000, ##arg, 27);\ - } \ - } while (0) +#define INIT_PERF(kb) do { \ + const char *tmp; \ + struct timespec tv; \ + tmp = bundle_get_val(kb, AUL_K_STARTTIME); \ + if (tmp != NULL) \ + sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_nsec); \ + else \ + clock_gettime(CLOCK_MONOTONIC, &tv); \ + __g_base_time.tv_sec = tv.tv_sec; \ + __g_base_time.tv_nsec = tv.tv_nsec; \ +} while (0) + +#define PERF(fmt, arg...) do { \ + struct timespec cur; \ + struct timespec res; \ + clock_gettime(CLOCK_MONOTONIC, &cur); \ + if (__g_base_time.tv_sec != 0) { \ + res->tv_sec = cur.tv_sec - __g_base_time.tv_sec; \ + res->tv_nsec = cur.tv_nsec - __g_base_time.tv_nsec; \ + printf("%c[1;31m[%s,%d] %ld sec %ld msec "fmt \ + " %c[0m\n", 27, __func__, \ + __LINE__, res.tv_sec, \ + res.tv_nsec / 1e6, ##arg, 27); \ + } \ +} while (0) #else -- 2.7.4 From 91c66de283a78423238d5a9364c7814a5026e529 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 20 Dec 2019 13:45:12 +0900 Subject: [PATCH 05/16] Release version 0.10.2 Changes: - Use monotonic time Change-Id: Ie2c454ff5823f8b94db0b88dffff73c8f059b2f2 Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 0deb0e4..1581432 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.10.1 +Version: 0.10.2 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From dc5bfa56676c513bba15da0d2b3f324ca01632f8 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 30 Dec 2019 14:26:20 +0900 Subject: [PATCH 06/16] Remove compile warning messages Change-Id: I94eca9e33a0776784ae0cae1a52c5781eff84ce1 Signed-off-by: Hwankyu Jhun --- src/launchpad_common.c | 2 +- src/launchpad_hydra.c | 7 ++++++- src/launchpad_signal.c | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/launchpad_common.c b/src/launchpad_common.c index 39a1a58..26fce8b 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -1383,7 +1383,7 @@ static int __send_raw(int fd, int cmd, unsigned char *data, int datalen) int _send_message_to_logger(const char *tag, const char *format, ...) { - char fmt[PATH_MAX]; + char fmt[PATH_MAX - 256]; char buf[PATH_MAX]; va_list ap; int ret; diff --git a/src/launchpad_hydra.c b/src/launchpad_hydra.c index 5d43b5d..7ffb5bd 100644 --- a/src/launchpad_hydra.c +++ b/src/launchpad_hydra.c @@ -258,6 +258,11 @@ static int __create_client_socket(const char *path) int retry = CONNECT_RETRY_COUNT; int fd; + if (sizeof(addr.sun_path) <= strlen(path)) { + _E("lenght of path is too long"); + return -1; + } + fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); if (fd < 0) { _E("Failed to create socket(%s). errno(%d)", path, errno); @@ -265,7 +270,7 @@ static int __create_client_socket(const char *path) } addr.sun_family = AF_UNIX; - snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", path); + strncpy(addr.sun_path, path, sizeof(addr.sun_path) - strlen(path) - 1); while (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { if (errno != ETIMEDOUT || retry <= 0) { _E("Failed to connect socket(%s). errno(%d)", diff --git a/src/launchpad_signal.c b/src/launchpad_signal.c index e6a6503..8dbf565 100644 --- a/src/launchpad_signal.c +++ b/src/launchpad_signal.c @@ -128,7 +128,7 @@ static void __socket_garbage_collector(void) { DIR *dp; struct dirent *dentry = NULL; - char tmp[MAX_LOCAL_BUFSZ]; + char tmp[PATH_MAX]; snprintf(tmp, sizeof(tmp), "/run/aul/apps/%d", getuid()); dp = opendir(tmp); @@ -139,7 +139,7 @@ static void __socket_garbage_collector(void) if (!isdigit(dentry->d_name[0])) continue; - snprintf(tmp, MAX_LOCAL_BUFSZ, "/proc/%s", dentry->d_name); + snprintf(tmp, sizeof(tmp), "/proc/%s", dentry->d_name); if (access(tmp, F_OK) < 0) { /* Flawfinder: ignore */ _delete_sock_path(atoi(dentry->d_name), getuid()); continue; -- 2.7.4 From 7cf6d2936cb0ce9098a10c3364b517f7b02905a3 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 31 Dec 2019 09:14:46 +0900 Subject: [PATCH 07/16] Fix wrong implementation Change-Id: Ie65ecbb277f13df6102236748d8709e7a4ff2090 Signed-off-by: Hwankyu Jhun --- src/launchpad_hydra.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/launchpad_hydra.c b/src/launchpad_hydra.c index 7ffb5bd..f2c7779 100644 --- a/src/launchpad_hydra.c +++ b/src/launchpad_hydra.c @@ -270,7 +270,8 @@ static int __create_client_socket(const char *path) } addr.sun_family = AF_UNIX; - strncpy(addr.sun_path, path, sizeof(addr.sun_path) - strlen(path) - 1); + strncpy(addr.sun_path, path, sizeof(addr.sun_path)); + addr.sun_path[sizeof(addr.sun_path) - 1] = '\0'; while (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { if (errno != ETIMEDOUT || retry <= 0) { _E("Failed to connect socket(%s). errno(%d)", -- 2.7.4 From 494b322f06e7f29ea06fb6a8def8fc0435ef4674 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 31 Dec 2019 08:07:14 +0900 Subject: [PATCH 08/16] Release version 0.10.3 Changes: - Remove compile warning messages - Fix wrong implementation Change-Id: I67c9ece883875cbb7579110812ac84df1a8f145b Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 1581432..f1cc49e 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.10.2 +Version: 0.10.3 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 24f7e3ba66036cd1f26b9c98ca989e91fb08834a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 22 Jan 2020 09:45:28 +0900 Subject: [PATCH 09/16] Fix type The return value type of iniparser_getstring() is changed to "const char *". Change-Id: I85ad74f7019d6fdc9f861e894e29fd81263e2da6 Signed-off-by: Hwankyu Jhun --- src/launchpad_config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/launchpad_config.c b/src/launchpad_config.c index 5c459e8..8c74693 100644 --- a/src/launchpad_config.c +++ b/src/launchpad_config.c @@ -84,7 +84,7 @@ int _config_get_int_value(config_type_e type) return value; } -static char *__get_string_value(dictionary *d, const char *tag, +static const char *__get_string_value(dictionary *d, const char *tag, const char *key) { char buf[128]; @@ -106,7 +106,7 @@ int _config_init(void) { dictionary *d; char *val; - char *str; + const char *str; int ret; _D("config init"); -- 2.7.4 From 96f0974c960adf8e6b0c79ac59e999fd794ee498 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 22 Jan 2020 09:51:45 +0900 Subject: [PATCH 10/16] Release version 0.10.4 Changes: - Fix type Change-Id: I20100e2f21d6b708e4199703bd9fd0764e12681c Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index f1cc49e..0077851 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.10.3 +Version: 0.10.4 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From b772f01c490f3769e00b5cd2b20af4e97965547a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 22 Jan 2020 17:13:13 +0900 Subject: [PATCH 11/16] Fix static anlysis issue Change-Id: I8672a904fae3b77f158b4955f0383b76465d468b Signed-off-by: Hwankyu Jhun --- src/launchpad.c | 111 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 88 insertions(+), 23 deletions(-) diff --git a/src/launchpad.c b/src/launchpad.c index 16dc627..e751fbb 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -105,6 +105,8 @@ typedef struct { guint live_timer; int state; bool is_hydra; + guint pollfd; + guint hydra_pollfd; } candidate_process_context_t; typedef struct { @@ -2076,7 +2078,27 @@ end: return G_SOURCE_CONTINUE; } -static candidate_process_context_t *__add_slot(int type, int loader_id, +static void __destroy_slot(candidate_process_context_t *cpc) +{ + if (!cpc) + return; + + if (cpc->hydra_pollfd) + g_source_remove(cpc->hydra_pollfd); + + if (cpc->pollfd) + g_source_remove(cpc->pollfd); + + if (cpc->loader_extra) + free(cpc->loader_extra); + + if (cpc->loader_path) + free(cpc->loader_path); + + free(cpc); +} + +static candidate_process_context_t *__create_slot(int type, int loader_id, int caller_pid, const char *loader_path, const char *loader_extra, int detection_method, int activation_method, int deactivation_method, @@ -2085,16 +2107,27 @@ static candidate_process_context_t *__add_slot(int type, int loader_id, bool on_boot, bool app_exists, bool is_hydra) { candidate_process_context_t *cpc; - int fd = -1; - guint pollfd; - if (__find_slot(type, loader_id) != NULL) + cpc = calloc(1, sizeof(candidate_process_context_t)); + if (cpc == NULL) { + _E("Out of memory"); return NULL; + } - cpc = (candidate_process_context_t *)malloc( - sizeof(candidate_process_context_t)); - if (cpc == NULL) + cpc->loader_path = strdup(loader_path); + if (cpc->loader_path == NULL) { + _E("Failed to duplicate loader path(%s)", loader_path); + __destroy_slot(cpc); return NULL; + } + + cpc->loader_extra = loader_extra ? strdup(loader_extra) : strdup(""); + if (cpc->loader_extra == NULL) { + _E("Failed to duplicate loader extra(%s)", + loader_extra ? loader_extra : "null"); + __destroy_slot(cpc); + return NULL; + } cpc->type = type; cpc->prepared = false; @@ -2107,8 +2140,6 @@ static candidate_process_context_t *__add_slot(int type, int loader_id, cpc->last_exec_time = 0; cpc->source = 0; cpc->timer = 0; - cpc->loader_path = strdup(loader_path); - cpc->loader_extra = loader_extra ? strdup(loader_extra) : strdup(""); cpc->detection_method = detection_method; cpc->timeout_val = timeout_val; cpc->cpu_total_time = 0; @@ -2132,12 +2163,42 @@ static candidate_process_context_t *__add_slot(int type, int loader_id, else cpc->state = CANDIDATE_PROCESS_STATE_RUNNING; + return cpc; +} + +static candidate_process_context_t *__add_slot(int type, int loader_id, + int caller_pid, const char *loader_path, + const char *loader_extra, int detection_method, + int activation_method, int deactivation_method, + unsigned int ttl, int timeout_val, + int threshold_max, int threshold_min, + bool on_boot, bool app_exists, bool is_hydra) +{ + candidate_process_context_t *cpc; + int fd; + guint pollfd; + int hydra_fd; + guint hydra_pollfd; + + if (__find_slot(type, loader_id) != NULL) + return NULL; + + cpc = __create_slot(type, loader_id, + caller_pid, loader_path, + loader_extra, detection_method, + activation_method, deactivation_method, + ttl, timeout_val, + threshold_max, threshold_min, + on_boot, app_exists, is_hydra); + if (cpc == NULL) + return NULL; + fd = __listen_candidate_process(cpc->type, cpc->loader_id); if (fd == -1) { _E("[launchpad] Listening the socket to " \ "the type %d candidate process failed.", cpc->type); - free(cpc); + __destroy_slot(cpc); return NULL; } @@ -2145,29 +2206,37 @@ static candidate_process_context_t *__add_slot(int type, int loader_id, cpc->type, cpc->loader_id); if (pollfd == 0) { close(fd); - free(cpc); + __destroy_slot(cpc); return NULL; } + cpc->pollfd = pollfd; + if (is_hydra) { - fd = __listen_hydra_process(cpc->type, cpc->loader_id); - if (fd == -1) { + hydra_fd = __listen_hydra_process(cpc->type, cpc->loader_id); + if (hydra_fd == -1) { _E("[launchpad] Listening the socket to " \ "the type %d hydra process failed.", cpc->type); - free(cpc); + close(fd); + __destroy_slot(cpc); return NULL; } - pollfd = __poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_hydra_event, - cpc->type, cpc->loader_id); - if (pollfd == 0) { + hydra_pollfd = __poll_fd(hydra_fd, G_IO_IN, + (GSourceFunc)__handle_hydra_event, + cpc->type, cpc->loader_id); + if (hydra_pollfd == 0) { + close(hydra_fd); close(fd); - free(cpc); + __destroy_slot(cpc); return NULL; } + + cpc->hydra_pollfd = hydra_pollfd; } + candidate_slot_list = g_list_append(candidate_slot_list, cpc); return cpc; @@ -2185,11 +2254,7 @@ static int __remove_slot(int type, int loader_id) __dispose_candidate_process(cpc); candidate_slot_list = g_list_delete_link( candidate_slot_list, iter); - free(cpc->loader_path); - if (cpc->loader_extra) - free(cpc->loader_extra); - - free(cpc); + __destroy_slot(cpc); return 0; } -- 2.7.4 From 479332d45c45dd5057ca94fd98e42e3358713447 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 23 Jan 2020 11:04:14 +0900 Subject: [PATCH 12/16] Fix fd event handling - Uses GIOChannel instead of GSource Change-Id: Iaf999693e8da5b0830f015435d0ebf37accab91a Signed-off-by: Hwankyu Jhun --- CMakeLists.txt | 1 + inc/launchpad_io_channel.h | 38 ++++++ src/launchpad.c | 315 ++++++++++++++------------------------------- src/launchpad_io_channel.c | 159 +++++++++++++++++++++++ src/log_private.h | 17 ++- 5 files changed, 314 insertions(+), 216 deletions(-) create mode 100644 inc/launchpad_io_channel.h create mode 100644 src/launchpad_io_channel.c diff --git a/CMakeLists.txt b/CMakeLists.txt index ad32426..5239b49 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,6 +146,7 @@ SET(${LAUNCHPAD_PROCESS_POOL}_SOURCE_FILES src/launchpad_debug.c src/launchpad_signal.c src/launchpad_config.c + src/launchpad_io_channel.c ) ADD_EXECUTABLE(${LAUNCHPAD_PROCESS_POOL} ${${LAUNCHPAD_PROCESS_POOL}_SOURCE_FILES}) diff --git a/inc/launchpad_io_channel.h b/inc/launchpad_io_channel.h new file mode 100644 index 0000000..6498fb3 --- /dev/null +++ b/inc/launchpad_io_channel.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +typedef enum { + IO_IN = 0x01, + IO_OUT = 0x02, + IO_PRI = 0x04, + IO_ERR = 0x08, + IO_HUP = 0x10, + IO_NVAL = 0x20, +} io_condition_e; + +typedef bool (*io_channel_event_cb)(int fd, io_condition_e condition, + void *user_data); + +typedef struct io_channel_s *io_channel_h; + +io_channel_h _io_channel_create(int fd, io_condition_e condition, + io_channel_event_cb, void *user_data); + +void _io_channel_destroy(io_channel_h channel); diff --git a/src/launchpad.c b/src/launchpad.c index e751fbb..b847c2c 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -44,6 +44,7 @@ #include "launchpad_common.h" #include "launchpad_config.h" #include "launchpad_debug.h" +#include "launchpad_io_channel.h" #include "launchpad_signal.h" #include "launchpad_types.h" #include "loader_info.h" @@ -84,7 +85,6 @@ typedef struct { int send_fd; int hydra_fd; int last_exec_time; - guint source; guint timer; char *loader_path; char *loader_extra; @@ -105,8 +105,9 @@ typedef struct { guint live_timer; int state; bool is_hydra; - guint pollfd; - guint hydra_pollfd; + io_channel_h client_channel; + io_channel_h channel; + io_channel_h hydra_channel; } candidate_process_context_t; typedef struct { @@ -152,6 +153,11 @@ static sequencer __sequencer; static int MEMORY_STATUS_LOW; static int MEMORY_STATUS_NORMAL; +static io_channel_h __logger_channel; +static io_channel_h __label_monitor_channel; +static io_channel_h __sigchild_channel; +static io_channel_h __launchpad_channel; + static candidate_process_context_t *__add_slot(int type, int loader_id, int caller_pid, const char *loader_path, const char *extra, int detection_method, int activation_method, @@ -787,7 +793,7 @@ static void __reset_slot(candidate_process_context_t *cpc) cpc->send_fd = -1; cpc->prepared = false; cpc->pid = CANDIDATE_NONE; - cpc->source = 0; + cpc->client_channel = NULL; cpc->timer = 0; cpc->live_timer = 0; } @@ -804,8 +810,8 @@ static void __dispose_candidate_process(candidate_process_context_t *cpc) } if (cpc->live_timer > 0) g_source_remove(cpc->live_timer); - if (cpc->source > 0) - g_source_remove(cpc->source); + if (cpc->client_channel) + _io_channel_destroy(cpc->client_channel); if (cpc->timer > 0) g_source_remove(cpc->timer); if (cpc->send_fd > 0) @@ -1216,172 +1222,57 @@ static int __launchpad_pre_init(int argc, char **argv) return fd; } -static void __destroy_poll_data(gpointer data) -{ - free(data); -} - -static gboolean __glib_check(GSource *src) -{ - GSList *fd_list; - GPollFD *tmp; - - fd_list = src->poll_fds; - do { - tmp = (GPollFD *) fd_list->data; - if ((tmp->revents & (G_IO_IN | G_IO_PRI | G_IO_HUP | - G_IO_NVAL))) - return TRUE; - fd_list = fd_list->next; - } while (fd_list); - - return FALSE; -} - -static gboolean __glib_dispatch(GSource *src, GSourceFunc callback, - gpointer data) -{ - return callback(data); -} - -static gboolean __glib_prepare(GSource *src, gint *timeout) -{ - return FALSE; -} - -static void __glib_finalize(GSource *src) -{ - GSList *fd_list; - GPollFD *gpollfd; - - fd_list = src->poll_fds; - do { - gpollfd = (GPollFD *)fd_list->data; - close(gpollfd->fd); - g_free(gpollfd); - - fd_list = fd_list->next; - } while (fd_list); -} - -static GSourceFuncs funcs = { - .prepare = __glib_prepare, - .check = __glib_check, - .dispatch = __glib_dispatch, - .finalize = __glib_finalize -}; - -static guint __poll_fd(int fd, gushort events, GSourceFunc func, int type, - int loader_id) +static bool __handle_loader_client_event(int fd, io_condition_e cond, + void *data) { - int r; - GPollFD *gpollfd; - GSource *src; - loader_context_t *lc; - - src = g_source_new(&funcs, sizeof(GSource)); - if (!src) { - _E("out of memory"); - return 0; - } - - gpollfd = (GPollFD *)g_malloc(sizeof(GPollFD)); - if (!gpollfd) { - _E("out of memory"); - g_source_destroy(src); - return 0; - } - - gpollfd->events = events; - gpollfd->fd = fd; - - lc = malloc(sizeof(loader_context_t)); - if (lc == NULL) { - g_free(gpollfd); - g_source_destroy(src); - return 0; - } - - lc->gpollfd = gpollfd; - lc->type = type; - lc->loader_id = loader_id; - - g_source_add_poll(src, gpollfd); - g_source_set_callback(src, func, - (gpointer) lc, __destroy_poll_data); - g_source_set_priority(src, G_PRIORITY_DEFAULT); - - r = g_source_attach(src, NULL); - if (r == 0) { - g_free(gpollfd); - g_source_destroy(src); - return 0; - } - - return r; -} - -static gboolean __handle_loader_client_event(gpointer data) -{ - loader_context_t *lc = (loader_context_t *) data; - int type = lc->type; - int loader_id = lc->loader_id; - gushort revents = lc->gpollfd->revents; - candidate_process_context_t *cpc = __find_slot(type, loader_id); + candidate_process_context_t *cpc = data; if (cpc == NULL) - return G_SOURCE_REMOVE; + return false; - if (revents & (G_IO_HUP | G_IO_NVAL)) { - SECURE_LOGE("Type %d candidate process was " \ + if (cond & (IO_HUP | IO_NVAL)) { + SECURE_LOGE("Type %d candidate process was " "(POLLHUP|POLLNVAL), pid: %d", cpc->type, cpc->pid); cpc->pid = CANDIDATE_NONE; __dispose_candidate_process(cpc); __prepare_candidate_process(cpc->type, cpc->loader_id); - return G_SOURCE_REMOVE; + return false; } - return G_SOURCE_CONTINUE; + return true; + } -static gboolean __handle_hydra_client_event(gpointer data) +static bool __handle_hydra_client_event(int fd, io_condition_e cond, + void *data) { - loader_context_t *lc = (loader_context_t *)data; - int type = lc->type; - int loader_id = lc->loader_id; - gushort revents = lc->gpollfd->revents; - candidate_process_context_t *cpc = __find_slot(type, loader_id); + candidate_process_context_t *cpc = data; if (cpc == NULL) - return G_SOURCE_REMOVE; + return false; - if (revents & (G_IO_HUP | G_IO_NVAL)) { - SECURE_LOGE("Type %d hydra process was " \ + if (cond & (IO_HUP | IO_NVAL)) { + SECURE_LOGE("Type %d hydra process was " "(POLLHUP|POLLNVAL), pid: %d", cpc->type, cpc->hydra_pid); __dispose_hydra_process(cpc); __prepare_candidate_process(cpc->type, cpc->loader_id); - return G_SOURCE_REMOVE; + return false; } - return G_SOURCE_CONTINUE; + return true; } -static gboolean __handle_loader_event(gpointer data) +static bool __handle_loader_event(int fd, io_condition_e cond, void *data) { - loader_context_t *lc = (loader_context_t *) data; - int fd = lc->gpollfd->fd; - int type = lc->type; - int loader_id = lc->loader_id; + candidate_process_context_t *cpc = data; int client_fd; int client_pid; int ret; - candidate_process_context_t *cpc = __find_slot(type, loader_id); - if (cpc == NULL) - return G_SOURCE_REMOVE; + return false; if (!cpc->prepared) { ret = __accept_candidate_process(fd, &client_fd, &client_pid); @@ -1394,12 +1285,13 @@ static gboolean __handle_loader_event(gpointer data) cpc->prepared = true; cpc->send_fd = client_fd; - SECURE_LOGD("Type %d candidate process was connected," \ - " pid: %d", type, cpc->pid); - cpc->source = __poll_fd(client_fd, G_IO_IN | G_IO_HUP, - __handle_loader_client_event, type, - loader_id); - if (cpc->source == 0) + SECURE_LOGD("Type %d candidate process was connected, " + "pid: %d", cpc->type, cpc->pid); + cpc->client_channel = _io_channel_create(client_fd, + IO_IN | IO_HUP, + __handle_loader_client_event, + cpc); + if (!cpc->client_channel) close(client_fd); } } else { @@ -1407,36 +1299,32 @@ static gboolean __handle_loader_event(gpointer data) _E("Refused candidate process connection"); } - return G_SOURCE_CONTINUE; + return true; } -static gboolean __handle_hydra_event(gpointer data) +static bool __handle_hydra_event(int fd, io_condition_e cond, void *data) { - loader_context_t *lc = (loader_context_t *) data; - int fd = lc->gpollfd->fd; - int type = lc->type; - int loader_id = lc->loader_id; + candidate_process_context_t *cpc = data; int client_fd; int client_pid; int ret; - candidate_process_context_t *cpc = __find_slot(type, loader_id); - if (cpc == NULL) - return G_SOURCE_REMOVE; + return false; if (!cpc->prepared) { ret = __accept_candidate_process(fd, &client_fd, &client_pid); if (ret >= 0) { cpc->hydra_fd = client_fd; - SECURE_LOGD("Type %d hydra process was connected," \ - " pid: %d", type, cpc->hydra_pid); + SECURE_LOGD("Type %d hydra process was connected," + " pid: %d", cpc->type, cpc->hydra_pid); - cpc->source = __poll_fd(client_fd, G_IO_IN | G_IO_HUP, - __handle_hydra_client_event, type, - loader_id); - if (cpc->source == 0) + cpc->client_channel = _io_channel_create(client_fd, + IO_IN | IO_HUP, + __handle_hydra_client_event, + cpc); + if (!cpc->client_channel) close(client_fd); } } else { @@ -1444,14 +1332,12 @@ static gboolean __handle_hydra_event(gpointer data) _E("Refused hydra process connection"); } - return G_SOURCE_CONTINUE; + return true; } -static gboolean __handle_sigchild(gpointer data) +static bool __handle_sigchild(int fd, io_condition_e cond, void *data) { candidate_process_context_t *cpc; - loader_context_t *lc = (loader_context_t *) data; - int fd = lc->gpollfd->fd; struct signalfd_siginfo siginfo; ssize_t s; char *appid; @@ -1498,15 +1384,15 @@ static gboolean __handle_sigchild(gpointer data) } } while (s > 0); - return G_SOURCE_CONTINUE; + return true; } -static gboolean __handle_label_monitor(gpointer data) +static bool __handle_label_monitor(int fd, io_condition_e cond, void *data) { candidate_process_context_t *cpc; GList *iter = candidate_slot_list; - _D("__handle_label_monitor()"); + _D("%s()", __FUNCTION__); security_manager_app_labels_monitor_process(label_monitor); while (iter) { @@ -1525,7 +1411,7 @@ static gboolean __handle_label_monitor(gpointer data) iter = g_list_next(iter); } - return G_SOURCE_CONTINUE; + return true; } static float __interpolator(float input, int cpu_max, int cpu_min) @@ -1894,10 +1780,8 @@ static void __update_slot_state(candidate_process_context_t *cpc, int method) } } -static gboolean __handle_launch_event(gpointer data) +static bool __handle_launch_event(int fd, io_condition_e cond, void *data) { - loader_context_t *lc = (loader_context_t *) data; - int fd = lc->gpollfd->fd; bundle *kb = NULL; app_pkt_t *pkt = NULL; appinfo_t *menu_info = NULL; @@ -2075,7 +1959,7 @@ end: traceEnd(TTRACE_TAG_APPLICATION_MANAGER); - return G_SOURCE_CONTINUE; + return true; } static void __destroy_slot(candidate_process_context_t *cpc) @@ -2083,11 +1967,11 @@ static void __destroy_slot(candidate_process_context_t *cpc) if (!cpc) return; - if (cpc->hydra_pollfd) - g_source_remove(cpc->hydra_pollfd); + if (cpc->hydra_channel) + _io_channel_destroy(cpc->hydra_channel); - if (cpc->pollfd) - g_source_remove(cpc->pollfd); + if (cpc->channel) + _io_channel_destroy(cpc->channel); if (cpc->loader_extra) free(cpc->loader_extra); @@ -2138,7 +2022,6 @@ static candidate_process_context_t *__create_slot(int type, int loader_id, cpc->send_fd = -1; cpc->hydra_fd = -1; cpc->last_exec_time = 0; - cpc->source = 0; cpc->timer = 0; cpc->detection_method = detection_method; cpc->timeout_val = timeout_val; @@ -2176,9 +2059,9 @@ static candidate_process_context_t *__add_slot(int type, int loader_id, { candidate_process_context_t *cpc; int fd; - guint pollfd; + io_channel_h channel; int hydra_fd; - guint hydra_pollfd; + io_channel_h hydra_channel; if (__find_slot(type, loader_id) != NULL) return NULL; @@ -2202,15 +2085,14 @@ static candidate_process_context_t *__add_slot(int type, int loader_id, return NULL; } - pollfd = __poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_loader_event, - cpc->type, cpc->loader_id); - if (pollfd == 0) { + channel = _io_channel_create(fd, IO_IN, __handle_loader_event, cpc); + if (!channel) { close(fd); __destroy_slot(cpc); return NULL; } - cpc->pollfd = pollfd; + cpc->channel = channel; if (is_hydra) { hydra_fd = __listen_hydra_process(cpc->type, cpc->loader_id); @@ -2218,22 +2100,19 @@ static candidate_process_context_t *__add_slot(int type, int loader_id, _E("[launchpad] Listening the socket to " \ "the type %d hydra process failed.", cpc->type); - close(fd); __destroy_slot(cpc); return NULL; } - hydra_pollfd = __poll_fd(hydra_fd, G_IO_IN, - (GSourceFunc)__handle_hydra_event, - cpc->type, cpc->loader_id); - if (hydra_pollfd == 0) { + hydra_channel = _io_channel_create(hydra_fd, IO_IN, + __handle_hydra_event, cpc); + if (!hydra_channel) { close(hydra_fd); - close(fd); __destroy_slot(cpc); return NULL; } - cpc->hydra_pollfd = hydra_pollfd; + cpc->hydra_channel = hydra_channel; } @@ -2267,7 +2146,6 @@ static int __remove_slot(int type, int loader_id) static int __init_launchpad_fd(int argc, char **argv) { int fd = -1; - guint pollfd; fd = __launchpad_pre_init(argc, argv); if (fd < 0) { @@ -2275,9 +2153,9 @@ static int __init_launchpad_fd(int argc, char **argv) return -1; } - pollfd = __poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_launch_event, 0, - 0); - if (pollfd == 0) { + __launchpad_channel = _io_channel_create(fd, IO_IN, + __handle_launch_event, NULL); + if (!__launchpad_channel) { close(fd); return -1; } @@ -2288,7 +2166,6 @@ static int __init_launchpad_fd(int argc, char **argv) static int __init_sigchild_fd(void) { int fd = -1; - guint pollfd; fd = _signal_get_sigchld_fd(); if (fd < 0) { @@ -2296,8 +2173,9 @@ static int __init_sigchild_fd(void) return -1; } - pollfd = __poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_sigchild, 0, 0); - if (pollfd == 0) { + __sigchild_channel = _io_channel_create(fd, IO_IN, + __handle_sigchild, NULL); + if (!__sigchild_channel) { close(fd); return -1; } @@ -2309,7 +2187,6 @@ static int __init_label_monitor_fd(void) { int r; int fd = -1; - guint pollfd; r = security_manager_app_labels_monitor_init(&label_monitor); if (r != SECURITY_MANAGER_SUCCESS) @@ -2325,9 +2202,9 @@ static int __init_label_monitor_fd(void) goto err; } - pollfd = __poll_fd(fd, G_IO_IN, - (GSourceFunc)__handle_label_monitor, 0, 0); - if (pollfd == 0) + __label_monitor_channel = _io_channel_create(fd, IO_IN, + __handle_label_monitor, NULL); + if (!__label_monitor_channel) goto err; return 0; @@ -2590,18 +2467,16 @@ static int __register_vconf_events(void) return 0; } -static gboolean __handle_logger(gpointer data) +static bool __handle_logger(int fd, io_condition_e cond, void *data) { - loader_context_t *lc = (loader_context_t *)data; - int fd = lc->gpollfd->fd; - app_pkt_t *pkt = NULL; + app_pkt_t *pkt; struct ucred cr; int clifd = -1; pkt = _accept_recv_pkt_raw(fd, &clifd, &cr); if (!pkt) { _E("Failed to receive the packet"); - return G_SOURCE_CONTINUE; + return true; } if (getuid() != cr.uid) { @@ -2615,20 +2490,18 @@ static gboolean __handle_logger(gpointer data) } SECURE_LOGE("[%d] %s", cr.pid, (const char *)pkt->data); - end: if (clifd != -1) close(clifd); - if (pkt) - free(pkt); - return G_SOURCE_CONTINUE; + free(pkt); + + return true; } static int __init_logger_fd(void) { int fd; - guint pollfd; fd = _create_server_sock(LAUNCHPAD_LOGGER_SOCK); if (fd < 0) { @@ -2636,8 +2509,8 @@ static int __init_logger_fd(void) return -1; } - pollfd = __poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_logger, 0, 0); - if (pollfd == 0) { + __logger_channel = _io_channel_create(fd, IO_IN, __handle_logger, NULL); + if (!__logger_channel) { close(fd); return -1; } @@ -2713,9 +2586,21 @@ static void __after_loop(void) _launcher_info_unload(launcher_info_list); _config_fini(); + if (__label_monitor_channel) + _io_channel_destroy(__label_monitor_channel); + if (label_monitor) security_manager_app_labels_monitor_finish(label_monitor); + if (__logger_channel) + _io_channel_destroy(__logger_channel); + + if (__launchpad_channel) + _io_channel_destroy(__launchpad_channel); + + if (__sigchild_channel) + _io_channel_destroy(__sigchild_channel); + __sequencer_fini(); } diff --git a/src/launchpad_io_channel.c b/src/launchpad_io_channel.c new file mode 100644 index 0000000..f20cb92 --- /dev/null +++ b/src/launchpad_io_channel.c @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define _GNU_SOURCE +#include +#include +#include +#include + +#include "launchpad_io_channel.h" +#include "log_private.h" + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) + +struct io_channel_s { + GIOChannel *io; + guint tag; + int fd; + io_channel_event_cb callback; + void *user_data; +}; + +struct io_condition_s { + io_condition_e io_cond; + GIOCondition g_io_cond; +}; + +static struct io_condition_s __cond_map[] = { + { + .io_cond = IO_IN, + .g_io_cond = G_IO_IN + }, + { + .io_cond = IO_OUT, + .g_io_cond = G_IO_OUT + }, + { + .io_cond = IO_PRI, + .g_io_cond = G_IO_PRI + }, + { + .io_cond = IO_ERR, + .g_io_cond = G_IO_ERR + }, + { + .io_cond = IO_HUP, + .g_io_cond = G_IO_HUP + }, + { + .io_cond = IO_NVAL, + .g_io_cond = G_IO_NVAL, + } +}; + +static io_condition_e __convert_g_io_condition(GIOCondition cond) +{ + io_condition_e condition = 0; + int i; + + for (i = 0; i < ARRAY_SIZE(__cond_map); i++) { + if (__cond_map[i].g_io_cond & cond) + condition |= __cond_map[i].io_cond; + } + + return condition; +} + +static GIOCondition __convert_io_condition(io_condition_e cond) +{ + GIOCondition condition = 0; + int i; + + for (i = 0; i < ARRAY_SIZE(__cond_map); i++) { + if (__cond_map[i].io_cond & cond) + condition |= __cond_map[i].g_io_cond; + } + + return condition; +} + +static gboolean __io_event_cb(GIOChannel *source, GIOCondition condition, + gpointer data) +{ + io_channel_h channel = (io_channel_h)data; + io_condition_e cond = __convert_g_io_condition(condition); + + if (!channel->callback(channel->fd, cond, channel->user_data)) + return G_SOURCE_REMOVE; + + return G_SOURCE_CONTINUE; +} + +io_channel_h _io_channel_create(int fd, io_condition_e cond, + io_channel_event_cb callback, void *user_data) +{ + struct io_channel_s *channel; + + if (fd < 3 || !callback) { + _E("Invalid parameter"); + return NULL; + } + + channel = calloc(1, sizeof(struct io_channel_s)); + if (!channel) { + _E("Out of memory"); + return NULL; + } + + channel->io = g_io_channel_unix_new(fd); + if (!channel->io) { + _E("Failed to create GIOChannel"); + _io_channel_destroy(channel); + return NULL; + } + + channel->tag = g_io_add_watch(channel->io, __convert_io_condition(cond), + __io_event_cb, channel); + if (!channel->tag) { + _E("Failed to add GIO watch"); + _io_channel_destroy(channel); + return NULL; + } + + channel->fd = fd; + channel->callback = callback; + channel->user_data = user_data; + + return channel; +} + +void _io_channel_destroy(io_channel_h channel) +{ + if (!channel) + return; + + if (channel->tag) + g_source_remove(channel->tag); + + if (channel->io) + g_io_channel_unref(channel->io); + + if (channel->fd) + close(channel->fd); + + free(channel); +} diff --git a/src/log_private.h b/src/log_private.h index f214b78..c3b0662 100644 --- a/src/log_private.h +++ b/src/log_private.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2019 - 2020 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,24 @@ #endif #define LOG_TAG "LAUNCHPAD" +#ifdef _E +#undef _E +#endif #define _E(fmt, arg...) LOGE(fmt, ##arg) + +#ifdef _D +#undef _D +#endif #define _D(fmt, arg...) LOGD(fmt, ##arg) + +#ifdef _W +#undef _W +#endif #define _W(fmt, arg...) LOGW(fmt, ##arg) + +#ifdef _I +#undef _I +#endif #define _I(fmt, arg...) LOGI(fmt, ##arg) #endif /* __LOG_PRIVATE_H__ */ -- 2.7.4 From 580f80d74fcb4141abecfaa49e412dde51e2222f Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 30 Jan 2020 07:39:28 +0900 Subject: [PATCH 13/16] Release version 0.10.5 Changes: - Fix static anlysis issue - Fix fd event handling Change-Id: I9e0900116218b2a46bd3bc7ea4dbf43d50b9181e Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 0077851..b89d29a 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.10.4 +Version: 0.10.5 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 643f4aea6eb710e2430b61b3f6e95228cd69a7f3 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 22 Jan 2020 15:02:40 +0900 Subject: [PATCH 14/16] Support launching service app with dynamic loader Change-Id: If385128a84a89e2e75d038ef5abe7ab6181c7402 Signed-off-by: Hwankyu Jhun --- src/launchpad.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/launchpad.c b/src/launchpad.c index b847c2c..ecd3f61 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -1890,7 +1890,15 @@ static bool __handle_launch_event(int fd, io_condition_e cond, void *data) if (menu_info->comp_type && strcmp(menu_info->comp_type, "svcapp") == 0) { - loader_id = PAD_LOADER_ID_DIRECT; + loader_id = __get_loader_id(kb); + if (loader_id > PAD_LOADER_ID_DYNAMIC_BASE) { + type = LAUNCHPAD_TYPE_DYNAMIC; + cpc = __find_slot(type, loader_id); + if (cpc && !cpc->prepared) + cpc = NULL; + } else { + loader_id = PAD_LOADER_ID_DIRECT; + } } else if (menu_info->comp_type && menu_info->app_type && strcmp(menu_info->comp_type, "widgetapp") == 0 && strcmp(menu_info->app_type, "webapp") == 0) { -- 2.7.4 From 1b870b7bc75c1f616d1058d2f9e06fab01b66cf5 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 31 Jan 2020 08:50:07 +0900 Subject: [PATCH 15/16] Release version 0.11.0 Changes: - Support launching service app with dynamic loader Change-Id: I568521232e4d1fcaf6797f67bd40f961bbdc4b79 Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index b89d29a..76464ea 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.10.5 +Version: 0.11.0 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 0c3dace9197251b325a77a22dc0d9726b168dc0d Mon Sep 17 00:00:00 2001 From: hyunho Date: Mon, 3 Feb 2020 11:29:49 +0900 Subject: [PATCH 16/16] Add a plugin for app-defined loader Change-Id: I73f527421a98bc619266171553280acd9029c61d Signed-off-by: hyunho --- CMakeLists.txt | 3 + packaging/launchpad.spec | 4 + parser/CMakeLists.txt | 39 ++++++ parser/common.hh | 25 ++++ parser/launchpad_parser_plugin.cc | 146 +++++++++++++++++++++ parser/launchpad_parser_plugin.hh | 45 +++++++ parser/launchpad_parser_plugin_pkgmgr_interface.cc | 68 ++++++++++ parser/launchpad_plugins.txt | 1 + parser/loader_info.cc | 44 +++++++ parser/loader_info.hh | 43 ++++++ parser/log_private.hh | 47 +++++++ 11 files changed, 465 insertions(+) create mode 100644 parser/CMakeLists.txt create mode 100644 parser/common.hh create mode 100644 parser/launchpad_parser_plugin.cc create mode 100644 parser/launchpad_parser_plugin.hh create mode 100644 parser/launchpad_parser_plugin_pkgmgr_interface.cc create mode 100644 parser/launchpad_plugins.txt create mode 100644 parser/loader_info.cc create mode 100644 parser/loader_info.hh create mode 100644 parser/log_private.hh diff --git a/CMakeLists.txt b/CMakeLists.txt index 5239b49..20d8f0f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,3 +203,6 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/inc/launchpad_hydra.h DESTINATION incl CONFIGURE_FILE(liblaunchpad-hydra.pc.in liblaunchpad-hydra.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblaunchpad-hydra.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) + +# parser +ADD_SUBDIRECTORY(parser) \ No newline at end of file diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 76464ea..babb8b4 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -26,6 +26,7 @@ BuildRequires: pkgconfig(libcap) BuildRequires: pkgconfig(tanchor) BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(iniparser) +BuildRequires: pkgconfig(libxml-2.0) Requires(post): /sbin/ldconfig Requires(post): /usr/bin/systemctl @@ -119,6 +120,7 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %install rm -rf %{buildroot} + %make_install mkdir -p %{buildroot}%{_unitdir_user}/basic.target.wants mkdir -p %{buildroot}%{_unitdir_user}/sockets.target.wants @@ -139,6 +141,8 @@ ln -sf ../launchpad-process-pool.service %{buildroot}%{_unitdir_user}/basic.targ %{_unitdir_user}/basic.target.wants/launchpad-process-pool.service %{_bindir}/launchpad-process-pool %{_prefix}/share/aul/launchpad.conf +%{_sysconfdir}/package-manager/parserlib/liblaunchpad-parser.so +%{_datadir}/parser-plugins/* %files devel %{_includedir}/launchpad/*.h diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt new file mode 100644 index 0000000..f98579f --- /dev/null +++ b/parser/CMakeLists.txt @@ -0,0 +1,39 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(launchpad-parser CXX) + +INCLUDE(FindPkgConfig) +pkg_check_modules(PKGS REQUIRED + dlog + libxml-2.0 +) + +FOREACH(FLAGS ${PKGS_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${FLAGS}") +ENDFOREACH(FLAGS) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline -std=c++11") + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_CXX_FLAGS_RELEASE "-O2") + +ADD_LIBRARY(${PROJECT_NAME} SHARED + launchpad_parser_plugin.cc + loader_info.cc + launchpad_parser_plugin_pkgmgr_interface.cc +) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) + +SET(PLUGINS_LIST_FILE_NAME launchpad_plugins.txt) +SET(PLUGINS_LIST_FILE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${PLUGINS_LIST_FILE_NAME}) + +SET(PLUGINS_LIST_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/share/parser-plugins) + +ADD_DEFINITIONS("-DPLUGINS_LIST_INSTALL_PATH=\"${PLUGINS_LIST_INSTALL_PATH}\"") + +INSTALL(FILES ${PLUGINS_LIST_FILE_PATH} DESTINATION ${PLUGINS_LIST_INSTALL_PATH}/) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PKGS_LDFLAGS}) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${SYSCONF_INSTALL_DIR}/package-manager/parserlib) diff --git a/parser/common.hh b/parser/common.hh new file mode 100644 index 0000000..910caa5 --- /dev/null +++ b/parser/common.hh @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LAUNCHPAD_PARSER_PLUGIN_COMMON_HH_ +#define LAUNCHPAD_PARSER_PLUGIN_COMMON_HH_ + +#ifdef EXPORT_API +#undef EXPORT_API +#endif +#define EXPORT_API __attribute__((visibility("default"))) + +#endif // LAUNCHPAD_PARSER_PLUGIN_COMMON_HH_ diff --git a/parser/launchpad_parser_plugin.cc b/parser/launchpad_parser_plugin.cc new file mode 100644 index 0000000..a880a6e --- /dev/null +++ b/parser/launchpad_parser_plugin.cc @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include +#include + +#include "launchpad_parser_plugin.hh" +#include "log_private.hh" + +#define LOADERS_DIRECTORY_PATH "/opt/share/loaders/" + +using namespace std; +namespace launchpad_parser_plugin { + +string LaunchpadParser::GetFilePath(string id) { + return "/opt/share/loaders/" + id + ".loader"; +} + +int LaunchpadParser::WriteToFile(string pkgid) { + if (access(LOADERS_DIRECTORY_PATH, F_OK) != 0) + mkdir(LOADERS_DIRECTORY_PATH, 0644); + + LOGI("write to file (%d)", loader_list_.size()); + for (auto& i : loader_list_) { + std::ofstream out_file; + LOGI("write ID (%s)", i->GetId().c_str()); + out_file.open(GetFilePath(i->GetId())); + out_file << "[LOADER]\n"; + out_file << "NAME " + i->GetId() + "\n"; + out_file << "EXE /usr/bin/launchpad-loader \n"; + out_file << "APP_TYPE capp|c++app \n"; + out_file << "DETECTION_METHOD TIMEOUT|VISIBILITY \n"; + out_file << "TIMEOUT 5000 \n"; + out_file << "TTL " + to_string(i->GetTimeToLive()) + "\n"; + out_file << "OWNER " + pkgid + "\n"; + out_file << "EXTRA loader_type common-loader \n"; + if (i->GetPreloadLib().size() > 0) { + out_file << "EXTRA_ARRAY preload \n"; + for (auto& lib : i->GetPreloadLib()) { + out_file << "EXTRA_ARRAY_VAL /usr/lib/" + lib + "\n"; + } + } + out_file.close(); + } + return 0; +} + +bool LaunchpadParser::IsValidId(string loader_id, string pkgid) { + ifstream in_file(GetFilePath(loader_id).c_str()); + if (!in_file.good()) + return true; + string key, val; + in_file >> key; + while (in_file >> key >> val) { + if (key == "OWNER") { + LOGI("key (%s), val (%s)", key.c_str(), val.c_str()); + if (val == pkgid) + return true; + } + } + return false; +} + +int LaunchpadParser::Install(xmlDocPtr doc, string pkgid) { + xmlNode* root = xmlDocGetRootElement(doc); + for (xmlNode* node = root->children; node; node = node->next) { + if (!node->name) + continue; + + string name = string((char*)node->name); + if (name != "provides-appdefined-loader") + continue; + + xmlChar* val = xmlGetProp(node, (const xmlChar *)"id"); + shared_ptr info = make_shared(string((char*)val)); + if (!IsValidId(info->GetId(), pkgid)) + return -1; + + xmlChar* ttl = xmlGetProp(node, (const xmlChar *)"time-to-live"); + if (ttl) + info->SetTimeToLive(stoi(string((char*)ttl))); + + for (xmlNode* iter = node->children; iter; iter = iter->next) { + if (!iter->name) + continue; + string child_name = string((char*)iter->name); + if (child_name == "preload-library") { + xmlChar* libname = xmlGetProp(iter, (const xmlChar *)"name"); + if (!libname) + continue; + info->AddPreloadLib(string((char*)libname)); + } + } + loader_list_.push_back(info); + } + WriteToFile(pkgid); + + return 0; +} + +int LaunchpadParser::Upgrade(xmlDocPtr doc, std::string pkgid) { + if (UnInstall(doc, pkgid) != 0) + return -1; + + return Install(doc, pkgid); +} + +int LaunchpadParser::UnInstall(xmlDocPtr doc, std::string pkgid) { + xmlNode* root = xmlDocGetRootElement(doc); + for (xmlNode* node = root->children; node; node = node->next) { + if (!node->name) + continue; + + string name = string((char*)node->name); + if (name != "provides-appdefined-loader") + continue; + + xmlChar* val = xmlGetProp(node, (const xmlChar *)"id"); + if (!val) + return -1; + + string id = string((char*)val); + if (!IsValidId(id, pkgid)) + return -1; + remove(GetFilePath(id).c_str()); + } + return 0; +} + +} // namspace launchpad_parser_plugin diff --git a/parser/launchpad_parser_plugin.hh b/parser/launchpad_parser_plugin.hh new file mode 100644 index 0000000..091e50c --- /dev/null +++ b/parser/launchpad_parser_plugin.hh @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LAUNCHPAD_PARSER_PLUGIN_LAUNCHPAD_PARSER_PLUGIN_HH_ +#define LAUNCHPAD_PARSER_PLUGIN_LAUNCHPAD_PARSER_PLUGIN_HH_ + +#include +#include +#include +#include + +#include "loader_info.hh" + +namespace launchpad_parser_plugin { + +class LaunchpadParser { + public: + std::string GetFilePath(std::string id); + int WriteToFile(std::string pkgid); + int Install(xmlDocPtr doc, std::string pkgid); + int Upgrade(xmlDocPtr doc, std::string pkgid); + int UnInstall(xmlDocPtr doc, std::string pkgid); + bool IsValidId(std::string loader_id, std::string pkgid); + + private: + std::list> loader_list_; +}; + +} // namespace launchpad_parser_plugin + +#endif // LAUNCHPAD_PARSER_PLUGIN_LAUNCHPAD_PARSER_PLUGIN_HH_ + diff --git a/parser/launchpad_parser_plugin_pkgmgr_interface.cc b/parser/launchpad_parser_plugin_pkgmgr_interface.cc new file mode 100644 index 0000000..34d16ba --- /dev/null +++ b/parser/launchpad_parser_plugin_pkgmgr_interface.cc @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "launchpad_parser_plugin.hh" +#include "log_private.hh" +#include "common.hh" + +using namespace launchpad_parser_plugin; + +extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr doc, const char *package) +{ + LaunchpadParser parser; + LOGI("install"); + return parser.Install(doc, package); +} + +extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr doc, const char *package) +{ + LOGI("uninstall"); + LaunchpadParser parser; + return parser.UnInstall(doc, package); +} + +extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr doc, const char *package) +{ + LOGI("upgrade"); + LaunchpadParser parser; + return parser.Upgrade(doc, package); +} + +extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_RECOVERINSTALL(xmlDocPtr doc, + const char *package) +{ + LOGW("recover install"); + LaunchpadParser parser; + return parser.UnInstall(doc, package); +} + +extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_RECOVERUNINSTALL(xmlDocPtr doc, + const char *package) +{ + LOGW("recover uninstall"); + LaunchpadParser parser; + return parser.UnInstall(doc, package); +} + +extern "C" EXPORT_API int PKGMGR_PARSER_PLUGIN_RECOVERUPGRADE(xmlDocPtr doc, + const char *package) +{ + LOGW("recover upgrade"); + LaunchpadParser parser; + return parser.Upgrade(doc, package); +} diff --git a/parser/launchpad_plugins.txt b/parser/launchpad_plugins.txt new file mode 100644 index 0000000..75a63d0 --- /dev/null +++ b/parser/launchpad_plugins.txt @@ -0,0 +1 @@ +type="tag";name="provides-appdefined-loader";path="/etc/package-manager/parserlib/liblaunchpad-parser.so";vitalness="true" diff --git a/parser/loader_info.cc b/parser/loader_info.cc new file mode 100644 index 0000000..1f6a2f5 --- /dev/null +++ b/parser/loader_info.cc @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "loader_info.hh" + +using namespace std; +namespace launchpad_parser_plugin { + +LoaderInfo::LoaderInfo(std::string id) : id_(id), time_to_live_(0) { +} + +string LoaderInfo::GetId() { + return id_; +} + +int LoaderInfo::GetTimeToLive() { + return time_to_live_; +} + +void LoaderInfo::SetTimeToLive(int time) { + time_to_live_ = time; +} + +list LoaderInfo::GetPreloadLib() { + return preload_lib_list_; +} + +void LoaderInfo::AddPreloadLib(string lib_name) { + preload_lib_list_.push_back(lib_name); +} + +} // namspace launchpad_parser_plugin diff --git a/parser/loader_info.hh b/parser/loader_info.hh new file mode 100644 index 0000000..c4ab4f3 --- /dev/null +++ b/parser/loader_info.hh @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LAUNCHPAD_PARSER_PLUGIN_LOADER_INFO_HH_ +#define LAUNCHPAD_PARSER_PLUGIN_LOADER_INFO_HH_ + +#include +#include + +namespace launchpad_parser_plugin { + +class LoaderInfo { + public: + LoaderInfo(std::string id); + std::string GetId(); + int GetTimeToLive(); + void SetTimeToLive(int time); + std::list GetPreloadLib(); + void AddPreloadLib(std::string lib_name); + + private: + std::string id_; + int time_to_live_; + std::list preload_lib_list_; +}; + +} // namespace launchpad_parser_plugin + +#endif // LAUNCHPAD_PARSER_PLUGIN_LOADER_INFO_HH_ + diff --git a/parser/log_private.hh b/parser/log_private.hh new file mode 100644 index 0000000..80e244b --- /dev/null +++ b/parser/log_private.hh @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LAUNCHPAD_PARSER_PLUGIN_LOG_PRIVATE_HH_ +#define LAUNCHPAD_PARSER_PLUGIN_LOG_PRIVATE_HH_ + +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "LAUNCHPAD_PARSER_PLUGIN" + +#ifdef _E +#undef _E +#endif +#define _E(fmt, arg...) LOGE(fmt, ##arg) + +#ifdef _D +#undef _D +#endif +#define _D(fmt, arg...) LOGD(fmt, ##arg) + +#ifdef _W +#undef _W +#endif +#define _W(fmt, arg...) LOGW(fmt, ##arg) + +#ifdef _I +#undef _I +#endif +#define _I(fmt, arg...) LOGI(fmt, ##arg) + +#endif /* LAUNCHPAD_PARSER_PLUGIN_LOG_PRIVATE_HH_ */ -- 2.7.4