if(::arg().asNum("receiver-threads") > 1) {
g_mustlockdistributor=true;
}
- for(int n=0; n < ::arg().asNum("receiver-threads"); ++n)
+ unsigned int max_rthreads= ::arg().asNum("receiver-threads");
+ for(int n=0; n < max_rthreads; ++n)
pthread_create(&qtid,0,qthread, reinterpret_cast<void *>(n)); // receives packets
void *p;
DNSSECKeeper::metacache_t DNSSECKeeper::s_metacache;
pthread_mutex_t DNSSECKeeper::s_metacachelock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t DNSSECKeeper::s_keycachelock = PTHREAD_MUTEX_INITIALIZER;
-unsigned int DNSSECKeeper::s_ops;
+AtomicCounter DNSSECKeeper::s_ops;
time_t DNSSECKeeper::s_last_prune;
bool DNSSECKeeper::isSecuredZone(const std::string& zone)
if(isPresigned(zone))
return true;
- if(!((s_ops++) % 100000)) {
+ if(!((++s_ops) % 100000)) {
cleanup();
}
value.clear();
unsigned int now = time(0);
- if(!((s_ops++) % 100000)) {
+ if(!((++s_ops) % 100000)) {
cleanup();
}
{
unsigned int now = time(0);
- if(!((s_ops++) % 100000)) {
+ if(!((++s_ops) % 100000)) {
cleanup();
}
int nextid;
time_t d_last_started;
int d_num_threads;
- int d_idle_threads;
+ AtomicCounter d_idle_threads;
Backend *b;
};
b=0;
d_overloaded = false;
nextid=0;
- d_idle_threads=0;
+ // d_idle_threads=0;
d_last_started=time(0);
// sem_init(&numquestions,0,0);
pthread_mutex_init(&q_lock,0);
// ick ick ick!
static int overloadQueueLength=::arg().asNum("overload-queue-length");
for(;;) {
- us->d_idle_threads++;
+ ++(us->d_idle_threads);
us->numquestions.getValue( &qcount );
us->numquestions.wait();
- us->d_idle_threads--;
+ --(us->d_idle_threads);
pthread_mutex_lock(&us->q_lock);
QuestionData QD=us->questions.front();
static metacache_t s_metacache;
static pthread_mutex_t s_metacachelock;
static pthread_mutex_t s_keycachelock;
- static unsigned int s_ops;
+ static AtomicCounter s_ops;
static time_t s_last_prune;
};
PacketCache::PacketCache()
{
pthread_rwlock_init(&d_mut,0);
- d_ops = 0;
+ // d_ops = 0;
d_ttl=-1;
d_recursivettl=-1;
if(d_ttl<0)
getTTLS();
- if(!((d_ops++) % 300000)) {
+ if(!((++d_ops) % 300000)) {
cleanup();
}
void PacketCache::insert(const string &qname, const QType& qtype, CacheEntryType cet, const string& value, unsigned int ttl, int zoneID,
bool meritsRecursion, unsigned int maxReplyLen, bool dnssecOk)
{
- if(!((d_ops++) % 300000)) {
+ if(!((++d_ops) % 300000)) {
cleanup();
}
if(d_ttl<0)
getTTLS();
- if(!((d_ops++) % 300000)) {
+ if(!((++d_ops) % 300000)) {
cleanup();
}
pthread_rwlock_t d_mut;
- unsigned int d_ops;
+ AtomicCounter d_ops;
int d_ttl;
int d_recursivettl;
bool d_doRecursion;
extern CommunicatorClass Communicator;
extern DNSProxy *DP;
-int PacketHandler::s_count;
+AtomicCounter PacketHandler::s_count;
extern string s_programname;
PacketHandler::PacketHandler():B(s_programname)
{
- s_count++;
+ ++s_count;
d_doFancyRecords = (::arg()["fancy-records"]!="no");
d_doRecursion= ::arg().mustDo("recursor");
d_logDNSDetails= ::arg().mustDo("log-dns-details");
bool addDSforNS(DNSPacket* p, DNSPacket* r, SOAData& sd, const string& dsname);
void completeANYRecords(DNSPacket *p, DNSPacket*r, SOAData& sd, const string &target);
- static int s_count;
+ static AtomicCounter s_count;
bool d_doFancyRecords;
bool d_doRecursion;
bool d_doCNAME;
#include <sstream>
#include "qtype.hh"
#include "misc.hh"
+#include "lock.hh"
+
+pthread_mutex_t QType::uninitlock = PTHREAD_MUTEX_INITIALIZER;
bool QType::uninit=true;
vector<QType::namenum> QType::names;
QType::QType()
{
+ Lock l(&uninitlock);
if(uninit)
{
uninit=false;
uint16_t code;
void insert(const char *p, int n);
-
+ static pthread_mutex_t uninitlock;
static bool uninit;
};
}
-int UeberBackend::handle::instances=0;
+AtomicCounter UeberBackend::handle::instances(0);
UeberBackend::handle::handle()
{
// L<<Logger::Warning<<"Handle instances: "<<instances<<endl;
- instances++;
+ ++instances;
}
UeberBackend::handle::~handle()
{
- instances--;
+ --instances;
}
bool UeberBackend::handle::get(DNSResourceRecord &r)
QType qtype;
private:
- static int instances;
+ static AtomicCounter instances;
};
void lookup(const QType &, const string &qdomain, DNSPacket *pkt_p=0, int zoneId=-1);