This also groups together 1) the list of frame stream servers, 2) the config from which
the list was created and 3) the config's generation into a single struct called
FrameStreamServersInfo. The struct is used to compare the old and new configuration to
decide whether to destroy the old config object or not.
Part of #11795
sr.setInitialRequestId(dc->d_uuid);
sr.setOutgoingProtobufServers(t_outgoingProtobufServers);
#ifdef HAVE_FSTRM
- sr.setFrameStreamServers(t_frameStreamServers);
+ sr.setFrameStreamServers(t_frameStreamServersInfo.servers);
#endif
bool useMapped = true;
/* DID YOU READ THE STORY ABOVE? */
+bool operator==(const FrameStreamExportConfig& configA, const FrameStreamExportConfig& configB)
+{
+ // clang-format off
+ return configA.enabled == configB.enabled &&
+ configA.logQueries == configB.logQueries &&
+ configA.logResponses == configB.logResponses &&
+ configA.bufferHint == configB.bufferHint &&
+ configA.flushTimeout == configB.flushTimeout &&
+ configA.inputQueueSize == configB.inputQueueSize &&
+ configA.outputQueueSize == configB.outputQueueSize &&
+ configA.queueNotifyThreshold == configB.queueNotifyThreshold &&
+ configA.reopenInterval == configB.reopenInterval &&
+ configA.servers == configB.servers;
+ // clang-format on
+}
+
+bool operator!=(const FrameStreamExportConfig& configA, const FrameStreamExportConfig& configB)
+{
+ return !(configA == configB);
+}
+
template <typename C>
typename C::value_type::second_type constGet(const C& c, const std::string& name)
{
#include "validate.hh"
#include "rec-zonetocache.hh"
#include "logging.hh"
+#include "fstrm_logger.hh"
struct ProtobufExportConfig
{
unsigned reopenInterval{0};
};
+bool operator==(const FrameStreamExportConfig& configA, const FrameStreamExportConfig& configB);
+bool operator!=(const FrameStreamExportConfig& configA, const FrameStreamExportConfig& configB);
+
+struct FrameStreamServersInfo
+{
+ std::shared_ptr<std::vector<std::unique_ptr<FrameStreamLogger>>> servers;
+ uint64_t generation;
+ FrameStreamExportConfig config;
+};
+
struct TrustAnchorFileInfo
{
uint32_t interval{24};
static thread_local uint64_t t_outgoingProtobufServersGeneration;
#ifdef HAVE_FSTRM
-thread_local std::shared_ptr<std::vector<std::unique_ptr<FrameStreamLogger>>> t_frameStreamServers{nullptr};
-thread_local uint64_t t_frameStreamServersGeneration;
+thread_local FrameStreamServersInfo t_frameStreamServersInfo;
#endif /* HAVE_FSTRM */
string g_programname = "pdns_recursor";
bool checkFrameStreamExport(LocalStateHolder<LuaConfigItems>& luaconfsLocal)
{
if (!luaconfsLocal->frameStreamExportConfig.enabled) {
- if (t_frameStreamServers) {
+ if (t_frameStreamServersInfo.servers) {
// dt's take care of cleanup
- t_frameStreamServers.reset();
+ t_frameStreamServersInfo.servers.reset();
+ t_frameStreamServersInfo.config = luaconfsLocal->frameStreamExportConfig;
}
return false;
}
- /* if the server was not running, or if it was running according to a
- previous configuration */
- if (!t_frameStreamServers || t_frameStreamServersGeneration < luaconfsLocal->generation) {
-
- if (t_frameStreamServers) {
+ /* if the server was not running, or if it was running according to a previous
+ * configuration
+ */
+ if (t_frameStreamServersInfo.generation < luaconfsLocal->generation && t_frameStreamServersInfo.config != luaconfsLocal->frameStreamExportConfig) {
+ if (t_frameStreamServersInfo.servers) {
// dt's take care of cleanup
- t_frameStreamServers.reset();
+ t_frameStreamServersInfo.servers.reset();
}
- auto log = g_slog->withName("dnstap");
- t_frameStreamServers = startFrameStreamServers(luaconfsLocal->frameStreamExportConfig, log);
- t_frameStreamServersGeneration = luaconfsLocal->generation;
+ auto dnsTapLog = g_slog->withName("dnstap");
+ t_frameStreamServersInfo.servers = startFrameStreamServers(luaconfsLocal->frameStreamExportConfig, dnsTapLog);
+ t_frameStreamServersInfo.config = luaconfsLocal->frameStreamExportConfig;
+ t_frameStreamServersInfo.generation = luaconfsLocal->generation;
}
return true;
#endif
#ifdef HAVE_FSTRM
-extern thread_local std::shared_ptr<std::vector<std::unique_ptr<FrameStreamLogger>>> t_frameStreamServers;
-extern thread_local uint64_t t_frameStreamServersGeneration;
+extern thread_local FrameStreamServersInfo t_frameStreamServersInfo;
#endif /* HAVE_FSTRM */
#ifdef HAVE_BOOST_CONTAINER_FLAT_SET_HPP