From: Hwankyu Jhun Date: Fri, 16 Jul 2021 11:16:46 +0000 (+0900) Subject: Get LAUNCHPAD_LISTEN_FD variable from the environment X-Git-Tag: submit/tizen/20210718.231655~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e4552fe6768c26a2d776718c3c6a4d526cdb55c;p=platform%2Fcore%2Fappfw%2Flaunchpad.git Get LAUNCHPAD_LISTEN_FD variable from the environment Currently, the file descriptior is not generated sequentially in some devices. The launchpad-process-pool is not always started by systemd. In this case, the program sets LAUNCHPAD_LISTEN_FD variable to the environment. After this patch is applied, the launchpad-process-pool tries to get the fd from the environment if calling sd_listen_fd() is failed. Change-Id: Ice99b52282b9ed7322acc185c150b6c8550d0d8d Signed-off-by: Hwankyu Jhun --- diff --git a/src/launchpad-process-pool/src/launchpad.c b/src/launchpad-process-pool/src/launchpad.c index be7a14a0..8bc1d78f 100644 --- a/src/launchpad-process-pool/src/launchpad.c +++ b/src/launchpad-process-pool/src/launchpad.c @@ -1385,18 +1385,37 @@ static int __create_sock_activation(void) return -1; } +static int __get_launchpad_listen_fd(void) +{ + const char *val; + + val = getenv("LAUNCHPAD_LISTEN_FD"); + if (!val) { + _E("Failed to get LAUNCHPAD_LISTEN_FD"); + return -1; + } + + _W("Listen Fd: %s", val); + return atoi(val); +} + static int __launchpad_pre_init(int argc, char **argv) { int fd; /* create launchpad sock */ fd = __create_sock_activation(); + if (fd >= 0) + return fd; + + fd = __get_launchpad_listen_fd(); + if (fd >= 0) + return fd; + + fd = _create_server_sock(PROCESS_POOL_LAUNCHPAD_SOCK); if (fd < 0) { - fd = _create_server_sock(PROCESS_POOL_LAUNCHPAD_SOCK); - if (fd < 0) { - _E("server sock error %d", fd); - return -1; - } + _E("server sock error %d", fd); + return -1; } return fd;