]> granicus.if.org Git - pdns/commitdiff
Fix comments from rgacogne
authorRobin Geuze <robing@transip.nl>
Mon, 6 Mar 2017 14:59:39 +0000 (15:59 +0100)
committerRobin Geuze <robing@transip.nl>
Mon, 6 Mar 2017 14:59:39 +0000 (15:59 +0100)
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.

pdns/dnsdist-lua2.cc
pdns/dnsdist-tcp.cc
pdns/dnsdist.cc
pdns/dnsdist.hh

index e582f53714fb9c5389b0f3a633e34797871765f8..abf3deec55764b729820ef29a75f4801c313e6f0 100644 (file)
@@ -653,7 +653,7 @@ void moreLua(bool client)
           const std::shared_ptr<ServerPool> 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<ServerPolicy>(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>(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";
index eadbd8cf965d002b9b030d4709d4ac06a099d836..75d1caf749b41fa871ae7492602a15a367c5e601 100644 (file)
@@ -365,7 +365,7 @@ void* tcpClientThread(int pipefd)
         std::shared_ptr<ServerPool> serverPool = getPool(*localPools, poolname);
         std::shared_ptr<DNSDistPacketCache> packetCache = nullptr;
         auto policy = localPolicy->policy;
-        if (serverPool->policy != NULL) {
+        if (serverPool->policy != nullptr) {
           policy = serverPool->policy->policy;
         }
         {
index d8e58b7b04a424f493a90a9e9990d6df46cce914..9e10eea9048dadf9082e7a92251df600c50ddac3 100644 (file)
@@ -692,7 +692,6 @@ std::shared_ptr<ServerPool> createPoolIfNotExists(pools_t& pools, const string&
     if (!poolName.empty())
       vinfolog("Creating pool %s", poolName);
     pool = std::make_shared<ServerPool>();
-    pool->policy = NULL;
     pools.insert(std::pair<std::string,std::shared_ptr<ServerPool> >(poolName, pool));
   }
   return pool;
@@ -1159,7 +1158,7 @@ try
       std::shared_ptr<ServerPool> serverPool = getPool(*localPools, poolname);
       std::shared_ptr<DNSDistPacketCache> packetCache = nullptr;
       auto policy = localPolicy->policy;
-      if (serverPool->policy != NULL) {
+      if (serverPool->policy != nullptr) {
         policy = serverPool->policy->policy;
       }
       {
index 180da4a71e268089aeeec0299b121c2766175dce..100dd43b90848c4fd802c6d1cd2ffd31753134f4 100644 (file)
@@ -616,7 +616,7 @@ struct ServerPool
 
   NumberedVector<shared_ptr<DownstreamState>> servers;
   std::shared_ptr<DNSDistPacketCache> packetCache{nullptr};
-  std::shared_ptr<ServerPolicy> policy;
+  std::shared_ptr<ServerPolicy> policy{nullptr};
 };
 using pools_t=map<std::string,std::shared_ptr<ServerPool>>;
 void setPoolPolicy(pools_t& pools, const string& poolName, std::shared_ptr<ServerPolicy> policy);