]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
merge small variant of patch by Mark Zealey as attached to 579. Should be a speedup...
authorBert Hubert <bert.hubert@netherlabs.nl>
Wed, 3 Oct 2012 13:01:37 +0000 (13:01 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Wed, 3 Oct 2012 13:01:37 +0000 (13:01 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2729 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/qtype.cc
pdns/qtype.hh

index 6c0e106fabd832435a1d78223ce13d95502cc0cc..89b3c67fe11160ab8e3e870ae10a7d7ad2fdde79 100644 (file)
 #include "misc.hh"
 #include "lock.hh"
 
-
-pthread_mutex_t QType::uninitlock = PTHREAD_MUTEX_INITIALIZER;
-bool QType::uninit=true;
 vector<QType::namenum> QType::names;
-
-void QType::insert(const char *p, int n)
-{
-  names.push_back(make_pair(string(p),n));
-}
-
+// XXX FIXME we need to do something with initializer order here!
+QType::init QType::initializer; 
 
 QType::QType()
 {
-  Lock l(&uninitlock);
-  if(uninit)
-    {
-      uninit=false;
-      insert("A",1);
-      insert("NS",2);
-      insert("CNAME",5);
-      insert("SOA",6);
-      insert("MR",9);
-      insert("PTR",12);
-      insert("HINFO",13);
-      insert("MX",15);
-      insert("TXT",16);
-      insert("RP",17);
-      insert("AFSDB", 18);
-      insert("SIG",24);
-      insert("KEY",25);
-      insert("AAAA",28);
-      insert("LOC",29);
-      insert("SRV",33);
-      insert("CERT", 37);
-      insert("A6",38);
-      insert("NAPTR",35);
-      insert("DS", 43);
-      insert("SSHFP", 44);
-      insert("RRSIG", 46);
-      insert("NSEC", 47);
-      insert("DNSKEY", 48);
-      insert("NSEC3", 50);
-      insert("NSEC3PARAM", 51);
-      insert("TLSA",52);
-      insert("SPF",99);
-      insert("IXFR",251);
-      insert("AXFR",252);
-      insert("ANY",255);
-      insert("URL",256);
-      insert("MBOXFW",257);
-      insert("CURL",258);
-      insert("ADDR",259);
-      insert("DLV",32769);
-    }
 }
 
 uint16_t QType::getCode() const
index 1eb328b740232c141f0e0307f0dd1133bf6895bf..9115cdfabce941e2f09a165b0bda575811c7d79f 100644 (file)
@@ -82,12 +82,57 @@ public:
                 TLSA=52, SPF=99, TSIG=250, AXFR=252, IXFR=251, ANY=255, URL=256, MBOXFW=257, CURL=258, ADDR=259, DLV=32769} types;
   typedef pair<string,uint16_t> namenum; 
   static vector<namenum> names;
+
 private:
-  uint16_t code;
-  void insert(const char *p, int n);
+  static class init {
+    public:
+    void qtype_insert(const char* a, uint16_t num) 
+    {
+       names.push_back(make_pair(string(a), num));
+    }
+
+    init()
+    {
+      qtype_insert("A",1);
+      qtype_insert("NS",2);
+      qtype_insert("CNAME",5);
+      qtype_insert("SOA",6);
+      qtype_insert("MR",9);
+      qtype_insert("PTR",12);
+      qtype_insert("HINFO",13);
+      qtype_insert("MX",15);
+      qtype_insert("TXT",16);
+      qtype_insert("RP",17);
+      qtype_insert("AFSDB", 18);
+      qtype_insert("SIG",24);
+      qtype_insert("KEY",25);
+      qtype_insert("AAAA",28);
+      qtype_insert("LOC",29);
+      qtype_insert("SRV",33);
+      qtype_insert("CERT", 37);
+      qtype_insert("A6",38);
+      qtype_insert("NAPTR",35);
+      qtype_insert("DS", 43);
+      qtype_insert("SSHFP", 44);
+      qtype_insert("RRSIG", 46);
+      qtype_insert("NSEC", 47);
+      qtype_insert("DNSKEY", 48);
+      qtype_insert("NSEC3", 50);
+      qtype_insert("NSEC3PARAM", 51);
+      qtype_insert("TLSA",52);
+      qtype_insert("SPF",99);
+      qtype_insert("IXFR",251);
+      qtype_insert("AXFR",252);
+      qtype_insert("ANY",255);
+      qtype_insert("URL",256);
+      qtype_insert("MBOXFW",257);
+      qtype_insert("CURL",258);
+      qtype_insert("ADDR",259);
+      qtype_insert("DLV",32769);
+    }
+  } initializer;
 
-  static pthread_mutex_t uninitlock;
-  static bool uninit;
+  uint16_t code;
 };
 
 struct QClass