From: Robin Geuze Date: Mon, 6 Mar 2017 14:59:39 +0000 (+0100) Subject: Fix comments from rgacogne X-Git-Tag: rec-4.1.0-alpha1~228^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b9f8a6c8b38c0dbb19e2c206221cf3f3b0da22b6;p=pdns Fix comments from rgacogne Use nullptr instead of NULL Statically initialize policy to nullptr in Pool object Actually set the global state for the pools after setting a new server selection policy on a pool. --- diff --git a/pdns/dnsdist-lua2.cc b/pdns/dnsdist-lua2.cc index e582f5371..abf3deec5 100644 --- a/pdns/dnsdist-lua2.cc +++ b/pdns/dnsdist-lua2.cc @@ -653,7 +653,7 @@ void moreLua(bool client) const std::shared_ptr pool = entry.second; string cache = pool->packetCache != nullptr ? pool->packetCache->toString() : ""; string policy = g_policy.getLocal()->name; - if (pool->policy != NULL) { + if (pool->policy != nullptr) { policy = pool->policy->name; } string servers; @@ -1300,19 +1300,21 @@ void moreLua(bool client) setLuaSideEffect(); auto localPools = g_pools.getCopy(); setPoolPolicy(localPools, pool, std::make_shared(policy)); + g_pools.setState(localPools); }); g_lua.writeFunction("setPoolServerPolicyLua", [](string name, policyfunc_t policy, string pool) { setLuaSideEffect(); auto localPools = g_pools.getCopy(); setPoolPolicy(localPools, pool, std::make_shared(ServerPolicy{name, policy})); + g_pools.setState(localPools); }); g_lua.writeFunction("showPoolServerPolicy", [](string pool) { setLuaSideEffect(); auto localPools = g_pools.getCopy(); auto poolObj = getPool(localPools, pool); - if (poolObj->policy == NULL) { + if (poolObj->policy == nullptr) { g_outputBuffer=g_policy.getLocal()->name+"\n"; } else { g_outputBuffer=poolObj->policy->name+"\n"; diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index eadbd8cf9..75d1caf74 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -365,7 +365,7 @@ void* tcpClientThread(int pipefd) std::shared_ptr serverPool = getPool(*localPools, poolname); std::shared_ptr packetCache = nullptr; auto policy = localPolicy->policy; - if (serverPool->policy != NULL) { + if (serverPool->policy != nullptr) { policy = serverPool->policy->policy; } { diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index d8e58b7b0..9e10eea90 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -692,7 +692,6 @@ std::shared_ptr createPoolIfNotExists(pools_t& pools, const string& if (!poolName.empty()) vinfolog("Creating pool %s", poolName); pool = std::make_shared(); - pool->policy = NULL; pools.insert(std::pair >(poolName, pool)); } return pool; @@ -1159,7 +1158,7 @@ try std::shared_ptr serverPool = getPool(*localPools, poolname); std::shared_ptr packetCache = nullptr; auto policy = localPolicy->policy; - if (serverPool->policy != NULL) { + if (serverPool->policy != nullptr) { policy = serverPool->policy->policy; } { diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index 180da4a71..100dd43b9 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -616,7 +616,7 @@ struct ServerPool NumberedVector> servers; std::shared_ptr packetCache{nullptr}; - std::shared_ptr policy; + std::shared_ptr policy{nullptr}; }; using pools_t=map>; void setPoolPolicy(pools_t& pools, const string& poolName, std::shared_ptr policy);