From: Naoto Yamaguchi Date: Sun, 5 Jun 2022 14:40:12 +0000 (+0900) Subject: Add systemd notify support X-Git-Tag: 13.93.0^0 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Fdrm-lease-manager.git;a=commitdiff_plain;h=f20fa3f4f0a2698db38d993e3d0b86be58c41ef2 Add systemd notify support The drm-lease-manager create unix domain socket file to provide lease to lease client. In typical case, this file must be create before client boot up. But existing drm-lease-manager couldn't keep that sequence because that support startup ordering only using systemd service dependency. This patch add systemd notify support to realize more strictly ordaining. Bug-AGL: SPEC-4427 Signed-off-by: Naoto Yamaguchi Change-Id: Icaad6c9df0696a48b9534c7586be7949a874f9a5 --- diff --git a/drm-lease-manager/main.c b/drm-lease-manager/main.c index b4ad379..5ac3600 100644 --- a/drm-lease-manager/main.c +++ b/drm-lease-manager/main.c @@ -13,6 +13,7 @@ * limitations under the License. */ +#include "config.h" #include "lease-config.h" #include "lease-manager.h" #include "lease-server.h" @@ -23,6 +24,10 @@ #include #include +#ifdef HAVE_SYSTEMD_DAEMON +#include +#endif + static void usage(const char *progname) { printf("Usage: %s [OPTIONS] []\n\n" @@ -107,6 +112,10 @@ int main(int argc, char **argv) return EXIT_FAILURE; } +#ifdef HAVE_SYSTEMD_DAEMON + sd_notify(1, "READY=1"); +#endif + struct ls_req req; while (ls_get_request(ls, &req)) { switch (req.type) { diff --git a/drm-lease-manager/meson.build b/drm-lease-manager/meson.build index 4732283..d8c48c7 100644 --- a/drm-lease-manager/meson.build +++ b/drm-lease-manager/meson.build @@ -4,7 +4,8 @@ lease_server_files = files('lease-server.c') lease_config_files = files('lease-config.c') main = executable('drm-lease-manager', [ 'main.c', lease_manager_files, lease_server_files, lease_config_files ], - dependencies: [ drm_dep, dlmcommon_dep, thread_dep, toml_dep ], + dependencies: [ drm_dep, dlmcommon_dep, thread_dep, toml_dep, systemd_dep ], + include_directories : configuration_inc, install: true, ) diff --git a/meson.build b/meson.build index c2c88a6..1694a0a 100644 --- a/meson.build +++ b/meson.build @@ -28,15 +28,17 @@ add_project_arguments( language: 'c' ) -configure_file(output: 'config.h', - configuration: config) - -configuration_inc = include_directories('.') - drm_dep = dependency('libdrm', version: '>= 2.4.89') thread_dep = dependency('threads') toml_dep = dependency('libtoml') +systemd_dep = dependency('', required: false) +if get_option('enable-systemd') + systemd_dep = dependency('libsystemd', required: false) + + config.set('HAVE_SYSTEMD_DAEMON', '1') +endif + enable_tests = get_option('enable-tests') if enable_tests @@ -56,6 +58,11 @@ if enable_tests endif endif +configure_file(output: 'config.h', + configuration: config) + +configuration_inc = include_directories('.') + subdir('common') subdir('libdlmclient') subdir('drm-lease-manager') diff --git a/meson_options.txt b/meson_options.txt index ee1f8dc..7774174 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -10,6 +10,12 @@ option('enable-tests', description: 'Build unit tests' ) +option('enable-systemd', + type: 'boolean', + value: false, + description: 'Systemd notify support' +) + option('runtime_subdir', type: 'string', value: 'run/drm-lease-manager',