From: Remi Gacogne Date: Tue, 9 Nov 2021 10:58:57 +0000 (+0100) Subject: dnsdist: Do not build carbon support when DISABLE_CARBON is defined X-Git-Tag: auth-4.7.0-alpha1~103^2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac4c3e1c18621e30fadb899a7f80d943f21f41f9;p=thirdparty%2Fpdns.git dnsdist: Do not build carbon support when DISABLE_CARBON is defined --- diff --git a/pdns/dnsdist-carbon.cc b/pdns/dnsdist-carbon.cc index e411c09bef..cb0bc5fdf4 100644 --- a/pdns/dnsdist-carbon.cc +++ b/pdns/dnsdist-carbon.cc @@ -25,18 +25,13 @@ #include "dnsdist-carbon.hh" #include "dnsdist.hh" -#include "dnsdist-carbon.hh" + +#ifndef DISABLE_CARBON #include "dolog.hh" #include "sstuff.hh" #include "threadname.hh" GlobalStateHolder > g_carbon; -static time_t s_start = time(nullptr); - -uint64_t uptimeOfProcess(const std::string& str) -{ - return time(nullptr) - s_start; -} void carbonDumpThread() { @@ -278,3 +273,11 @@ void carbonDumpThread() errlog("Carbon thread died"); } } +#endif /* DISABLE_CARBON */ + +static time_t s_start = time(nullptr); + +uint64_t uptimeOfProcess(const std::string& str) +{ + return time(nullptr) - s_start; +} diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index db5de00859..13bdb4de22 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -941,6 +941,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) return std::shared_ptr(nullptr); }); +#ifndef DISABLE_CARBON luaCtx.writeFunction("carbonServer", [](const std::string& address, boost::optional ourName, boost::optional interval, boost::optional namespace_name, boost::optional instance_name) { setLuaSideEffect(); auto ours = g_carbon.getCopy(); @@ -951,6 +952,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) interval ? *interval : 30}); g_carbon.setState(ours); }); +#endif /* DISABLE_CARBON */ luaCtx.writeFunction("webserver", [client, configCheck](const std::string& address, boost::optional password, boost::optional apiKey, const boost::optional> customHeaders, const boost::optional acl) { setLuaSideEffect(); diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 68933ea86e..3aee155b71 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -2691,8 +2691,10 @@ int main(int argc, char** argv) } } +#ifndef DISABLE_CARBON thread carbonthread(carbonDumpThread); carbonthread.detach(); +#endif /* DISABLE_CARBON */ thread stattid(maintThread); stattid.detach(); diff --git a/pdns/dnsdistdist/dnsdist-carbon.hh b/pdns/dnsdistdist/dnsdist-carbon.hh index 6dbb995419..226fa9a483 100644 --- a/pdns/dnsdistdist/dnsdist-carbon.hh +++ b/pdns/dnsdistdist/dnsdist-carbon.hh @@ -21,6 +21,9 @@ */ #pragma once +#include "config.h" + +#ifndef DISABLE_CARBON #include "sholder.hh" #include "iputils.hh" @@ -35,3 +38,4 @@ struct CarbonConfig extern GlobalStateHolder > g_carbon; void carbonDumpThread(); +#endif /* DISABLE_CARBON */