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 <h.jhun@samsung.com>
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;