Changeset 2328
- Timestamp:
- 01/04/12 10:42:47 (17 months ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 3 modified
-
cachecleaner.hh (modified) (1 diff)
-
dbdnsseckeeper.cc (modified) (6 diffs)
-
dnsseckeeper.hh (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/cachecleaner.hh
r1712 r2328 12 12 unsigned int cacheSize=collection.size(); 13 13 14 if( maxCached &&cacheSize > maxCached) {14 if(cacheSize > maxCached) { 15 15 toTrim = cacheSize - maxCached; 16 16 } -
trunk/pdns/pdns/dbdnsseckeeper.cc
r2216 r2328 31 31 #include <boost/assign/list_inserter.hpp> 32 32 #include "base64.hh" 33 #include "cachecleaner.hh" 34 #include "arguments.hh" 33 35 34 36 … … 41 43 pthread_mutex_t DNSSECKeeper::s_metacachelock = PTHREAD_MUTEX_INITIALIZER; 42 44 pthread_mutex_t DNSSECKeeper::s_keycachelock = PTHREAD_MUTEX_INITIALIZER; 45 unsigned int DNSSECKeeper::s_ops; 46 time_t DNSSECKeeper::s_last_prune; 43 47 44 48 bool DNSSECKeeper::isSecuredZone(const std::string& zone) … … 47 51 return true; 48 52 53 if(!((s_ops++) % 100000)) { 54 cleanup(); 55 } 56 49 57 { 50 58 Lock l(&s_keycachelock); … … 178 186 value.clear(); 179 187 unsigned int now = time(0); 188 189 if(!((s_ops++) % 100000)) { 190 cleanup(); 191 } 192 180 193 { 181 194 Lock l(&s_metacachelock); … … 265 278 { 266 279 unsigned int now = time(0); 280 281 if(!((s_ops++) % 100000)) { 282 cleanup(); 283 } 284 267 285 { 268 286 Lock l(&s_keycachelock); … … 371 389 return false; 372 390 } 391 392 void DNSSECKeeper::cleanup() 393 { 394 struct timeval now; 395 Utility::gettimeofday(&now, 0); 396 397 if(now.tv_sec - s_last_prune > (time_t)(30)) { 398 { 399 Lock l(&s_metacachelock); 400 pruneCollection(s_metacache, ::arg().asNum("max-cache-entries")); 401 } 402 { 403 Lock l(&s_keycachelock); 404 pruneCollection(s_keycache, ::arg().asNum("max-cache-entries")); 405 } 406 s_last_prune=time(0); 407 } 408 } -
trunk/pdns/pdns/dnsseckeeper.hh
r2153 r2328 152 152 > metacache_t; 153 153 154 void cleanup(); 155 154 156 static keycache_t s_keycache; 155 157 static metacache_t s_metacache; 156 158 static pthread_mutex_t s_metacachelock; 157 159 static pthread_mutex_t s_keycachelock; 160 static unsigned int s_ops; 161 static time_t s_last_prune; 158 162 }; 159 163