From: Bert Hubert Date: Tue, 30 Oct 2012 10:20:03 +0000 (+0000) Subject: implement read/write lock on the DNSSEC signature cache, plus actually CLEAN the... X-Git-Tag: auth-3.2-rc1~46 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ccc3f9ed0fdcdbd0457f5d8f10d72893ed0bc02c;p=thirdparty%2Fpdns.git implement read/write lock on the DNSSEC signature cache, plus actually CLEAN the cache every once in a while ;-) git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2836 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/dbdnsseckeeper.cc b/pdns/dbdnsseckeeper.cc index d6611837ba..d07ddebc21 100644 --- a/pdns/dbdnsseckeeper.cc +++ b/pdns/dbdnsseckeeper.cc @@ -1,6 +1,6 @@ /* PowerDNS Versatile Database Driven Nameserver - Copyright (C) 2001 - 2011 PowerDNS.COM BV + Copyright (C) 2001 - 2012 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as diff --git a/pdns/dnssecsigner.cc b/pdns/dnssecsigner.cc index a77693e5fd..df3cf35215 100644 --- a/pdns/dnssecsigner.cc +++ b/pdns/dnssecsigner.cc @@ -1,6 +1,6 @@ /* PowerDNS Versatile Database Driven Nameserver - Copyright (C) 2001 - 2011 PowerDNS.COM BV + Copyright (C) 2001 - 2012 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as @@ -109,8 +109,10 @@ void addSignature(DNSSECKeeper& dk, DNSBackend& db, const std::string& signer, c toSign.clear(); } -static pthread_mutex_t g_signatures_lock = PTHREAD_MUTEX_INITIALIZER; -static map, string> g_signatures; +static pthread_rwlock_t g_signatures_lock = PTHREAD_RWLOCK_INITIALIZER; +typedef map, string> signaturecache_t; +static signaturecache_t g_signatures; +static int g_cacheweekno; void fillOutRRSIG(DNSSECPrivateKey& dpk, const std::string& signQName, RRSIGRecordContent& rrc, vector >& toSign) { @@ -118,31 +120,33 @@ void fillOutRRSIG(DNSSECPrivateKey& dpk, const std::string& signQName, RRSIGReco const DNSCryptoKeyEngine* rc = dpk.getKey(); rrc.d_tag = drc.getTag(); rrc.d_algorithm = drc.d_algorithm; - string msg=getMessageForRRSET(signQName, rrc, toSign); // this is what we will hash & sign - pair lookup(rc->getPubKeyHash(), pdns_md5sum(msg)); + pair lookup(rc->getPubKeyHash(), pdns_md5sum(msg)); // this hash is a memory saving exercise bool doCache=1; if(doCache) { - Lock l(&g_signatures_lock); - if(g_signatures.count(lookup)) { - // cerr<<"Hit!"<second; return; } else ; // cerr<<"Miss!"<sign(msg); - //cerr<