]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
meson: properly detect libsystemd dependency
authorTomas Krizek <tomas.krizek@nic.cz>
Tue, 18 Jun 2019 14:53:37 +0000 (16:53 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 24 Jun 2019 14:03:34 +0000 (16:03 +0200)
daemon/main.c
meson.build
systemd/nosocket/kresd@.service.in

index 83d101bb36a2abd725e92a342846ef8dfaf9a668..3237b8f18e3bc5e81eb1fcc46c145d5ce5324d3e 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <lua.h>
 #include <uv.h>
-#ifdef HAS_SYSTEMD
+#if SYSTEMD_VERSION > 0
 #include <systemd/sd-daemon.h>
 #endif
 #include <libknot/error.h>
@@ -445,7 +445,7 @@ static int run_worker(uv_loop_t *loop, struct engine *engine, fd_array_t *ipc_se
        memcpy(&engine->ipc_set, ipc_set, sizeof(*ipc_set));
 
        /* Notify supervisor. */
-#ifdef HAS_SYSTEMD
+#if SYSTEMD_VERSION > 0
        sd_notify(0, "READY=1");
 #endif
        /* Run event loop */
@@ -457,7 +457,7 @@ static int run_worker(uv_loop_t *loop, struct engine *engine, fd_array_t *ipc_se
        return EXIT_SUCCESS;
 }
 
-#ifdef HAS_SYSTEMD
+#if SYSTEMD_VERSION >= 227
 static void free_sd_socket_names(char **socket_names, int count)
 {
        for (int i = 0; i < count; i++) {
@@ -670,7 +670,7 @@ int main(int argc, char **argv)
        ret = bind_sockets(&args.addrs_tls, true, &args.fds);
        if (ret) goto cleanup_args;
 
-#ifdef HAS_SYSTEMD
+#if SYSTEMD_VERSION >= 227
        /* Accept passed sockets from systemd supervisor. */
        char **socket_names = NULL;
        int sd_nsocks = sd_listen_fds_with_names(0, &socket_names);
index 4d9d96b4f85da43288377b4c0b9d0802d135c139..4d901fbb9b60bcebe15c4babff5dccdd13839a6e 100644 (file)
@@ -85,9 +85,10 @@ group = get_option('group')
 
 ## Systemd
 message('--- systemd socket activation ---')
-libsystemd = dependency('libsystemd', version: '>=227', required: false)
+libsystemd = dependency('libsystemd', required: false)
 systemd_files = get_option('systemd_files')
-if systemd_files == 'enabled' and not libsystemd.found()
+if systemd_files == 'enabled' and (
+    not libsystemd.found() or libsystemd.version().version_compare('<227'))
   error('systemd_files=enabled requires libsystemd >= 227')
 endif
 message('---------------------------')
@@ -133,7 +134,8 @@ conf_data.set_quoted('libzscanner_SONAME',
   libzscanner.get_pkgconfig_variable('soname'))
 conf_data.set_quoted('libknot_SONAME',
   libknot.get_pkgconfig_variable('soname'))
-conf_data.set('HAS_SYSTEMD', libsystemd.found())
+conf_data.set('SYSTEMD_VERSION',
+  libsystemd.found() ? libsystemd.version().to_int() : -1)
 conf_data.set('NOVERBOSELOG', not verbose_log)
 
 kresconfig = configure_file(
index d5be474ed883a62f7f4f94fda6e49a9641122d4e..284473362f994e37363cf3a286a8037199ea4178 100644 (file)
@@ -4,7 +4,7 @@ Documentation=man:kresd.systemd.nosocket(7)
 Documentation=man:kresd(8)
 
 [Service]
-Type=simple
+Type=notify
 WorkingDirectory=@systemd_work_dir@
 ExecStart=@sbin_dir@/kresd --config=@etc_dir@/kresd.conf --forks=1
 Restart=on-abnormal