]> granicus.if.org Git - pdns/commitdiff
recursor: add sd_notify() support
authorPieter Lexis <pieter.lexis@powerdns.com>
Mon, 25 Apr 2016 15:51:13 +0000 (17:51 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Wed, 4 May 2016 14:03:09 +0000 (16:03 +0200)
pdns/pdns_recursor.cc
pdns/recursordist/Makefile.am
pdns/recursordist/configure.ac
pdns/recursordist/m4/ax_arg_default_enable_disable.m4 [new symlink]
pdns/recursordist/m4/systemd.m4 [new symlink]

index 2978f11d9621a1fcd8039f80c961d2034bf909d2..7fecde0463c0b9b6924cf932f96f0309954db849 100644 (file)
@@ -88,6 +88,10 @@ extern SortList g_sortlist;
 #include "dnsmessage.pb.h"
 #endif
 
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-daemon.h>
+#endif
+
 #ifndef RECURSOR
 #include "statbag.hh"
 StatBag S;
@@ -2657,6 +2661,9 @@ int serviceMain(int argc, char*argv[])
 
   if(g_numThreads == 1) {
     L<<Logger::Warning<<"Operating unthreaded"<<endl;
+#ifdef HAVE_SYSTEMD
+    sd_notify(0, "READY=1");
+#endif
     recursorThread(0);
   }
   else {
@@ -2666,8 +2673,9 @@ int serviceMain(int argc, char*argv[])
       pthread_create(&tid, 0, recursorThread, (void*)(long)n);
     }
     void* res;
-
-
+#ifdef HAVE_SYSTEMD
+    sd_notify(0, "READY=1");
+#endif
     pthread_join(tid, &res);
   }
   return 0;
index 61e3eb8eb2bee031efbb74eae9cb86ddf65ea548..1e4a7578dd1005ea72be83f0e01d0650702c3045 100644 (file)
@@ -1,6 +1,6 @@
 JSON11_LIBS = $(top_srcdir)/ext/json11/libjson11.la
 
-AM_CPPFLAGS = $(LUA_CFLAGS) $(YAHTTP_CFLAGS) $(BOOST_CPPFLAGS) $(BOTAN110_CFLAGS) $(SANITIZER_FLAGS) -O3 -Wall -pthread -DSYSCONFDIR=\"${sysconfdir}\"
+AM_CPPFLAGS = $(LUA_CFLAGS) $(YAHTTP_CFLAGS) $(BOOST_CPPFLAGS) $(BOTAN110_CFLAGS) $(SANITIZER_FLAGS) -O3 -Wall -pthread -DSYSCONFDIR=\"${sysconfdir}\" $(SYSTEMD_CFLAGS)
 
 AM_CPPFLAGS += \
        -I$(top_srcdir)/ext/json11 \
@@ -136,7 +136,8 @@ pdns_recursor_LDADD = \
        $(YAHTTP_LIBS) \
        $(JSON11_LIBS) \
        $(OPENSSL_LIBS) \
-       $(BOOST_CONTEXT_LIBS)
+       $(BOOST_CONTEXT_LIBS) \
+       $(SYSTEMD_LIBS)
 
 pdns_recursor_LDFLAGS = $(AM_LDFLAGS) \
        $(OPENSSL_LDFLAGS)
index f67b816f64db8302819f4b1c4a778724fccc8679..681bd77f9e77a1c2e8e80be67f4963bd7331a919 100644 (file)
@@ -116,6 +116,8 @@ AS_IF([test "x$enable_hardening" != "xno"], [
 PDNS_ENABLE_SANITIZERS
 PDNS_ENABLE_MALLOC_TRACE
 PDNS_WITH_PROTOBUF
+AX_AVAILABLE_SYSTEMD
+AM_CONDITIONAL([HAVE_SYSTEMD], [ test x"$systemd" = "xy" ])
 PDNS_CHECK_PANDOC
 
 AC_SUBST(LIBS)
diff --git a/pdns/recursordist/m4/ax_arg_default_enable_disable.m4 b/pdns/recursordist/m4/ax_arg_default_enable_disable.m4
new file mode 120000 (symlink)
index 0000000..dcdfa5b
--- /dev/null
@@ -0,0 +1 @@
+../../../m4/ax_arg_default_enable_disable.m4
\ No newline at end of file
diff --git a/pdns/recursordist/m4/systemd.m4 b/pdns/recursordist/m4/systemd.m4
new file mode 120000 (symlink)
index 0000000..d95ceb7
--- /dev/null
@@ -0,0 +1 @@
+../../../m4/systemd.m4
\ No newline at end of file