]> granicus.if.org Git - pdns/commitdiff
reuse AuthLua4 object
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Mon, 3 Jun 2019 16:00:09 +0000 (18:00 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Mon, 3 Jun 2019 16:00:09 +0000 (18:00 +0200)
pdns/lua-record.cc

index 3ebed5dcd35e2034a17a65342877c24254a11a00..3d757415fedd6cf9f6508174f86782a4c48807b5 100644 (file)
@@ -465,13 +465,19 @@ static vector<pair<int, ComboAddress> > convWIplist(std::unordered_map<int, wipl
   return ret;
 }
 
+thread_local unique_ptr<AuthLua4> alua;
+
 std::vector<shared_ptr<DNSRecordContent>> luaSynth(const std::string& code, const DNSName& query, const DNSName& zone, int zoneid, const DNSPacket& dnsp, uint16_t qtype)
 {
-  AuthLua4 alua;
+  if(!alua) {
+    cerr<<"initializing AuthLua4"<<endl;
+
+    alua = make_unique<AuthLua4>();
+  }
 
   std::vector<shared_ptr<DNSRecordContent>> ret;
 
-  LuaContext& lua = *alua.getLua();
+  LuaContext& lua = *alua->getLua();
   lua.writeVariable("qname", query);
   lua.writeVariable("who", dnsp.getRemote());
   lua.writeVariable("dh", (dnsheader*)&dnsp.d);