From: Wouter Wijngaards Date: Wed, 17 Sep 2008 07:13:31 +0000 (+0000) Subject: threadsafe rrset counter. X-Git-Tag: release-1.1.0~111 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=62fc91f7f184eed5bbfb8d034223a7be4a91ae2d;p=thirdparty%2Funbound.git threadsafe rrset counter. git-svn-id: file:///svn/unbound/trunk@1240 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/daemon/stats.c b/daemon/stats.c index d62411403..89f9e5fd8 100644 --- a/daemon/stats.c +++ b/daemon/stats.c @@ -106,9 +106,11 @@ get_rrset_bogus(struct worker* worker) if(m == -1) return 0; ve = (struct val_env*)worker->env.modinfo[m]; + lock_basic_lock(&ve->bogus_lock); r = ve->num_rrset_bogus; if(!worker->env.cfg->stat_cumulative) ve->num_rrset_bogus = 0; + lock_basic_unlock(&ve->bogus_lock); return r; } diff --git a/doc/Changelog b/doc/Changelog index 0f9afb4ba..8f7424d41 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +17 September 2008: Wouter + - locking for threadsafe bogus rrset counter. + 16 September 2008: Wouter - extended-statistics: yesno config option. - unwanted replies spoof nearmiss detector. diff --git a/validator/val_utils.c b/validator/val_utils.c index 79351a8b0..144839695 100644 --- a/validator/val_utils.c +++ b/validator/val_utils.c @@ -341,7 +341,9 @@ val_verify_rrset(struct module_env* env, struct val_env* ve, d->ttl = ve->bogus_ttl; /* leave RR specific TTL: not used for determine * if RRset timed out and clients see proper value. */ + lock_basic_lock(&ve->bogus_lock); ve->num_rrset_bogus++; + lock_basic_unlock(&ve->bogus_lock); } /* if status updated - store in cache for reuse */ rrset_update_sec_status(env->rrset_cache, rrset, *env->now); diff --git a/validator/validator.c b/validator/validator.c index ec7f1241a..1f7d9c07e 100644 --- a/validator/validator.c +++ b/validator/validator.c @@ -154,6 +154,9 @@ val_init(struct module_env* env, int id) env->modinfo[id] = (void*)val_env; env->need_to_validate = 1; val_env->permissive_mode = 0; + lock_basic_init(&val_env->bogus_lock); + lock_protect(&val_env->bogus_lock, &val_env->num_rrset_bogus, + sizeof(val->env->num_rrset_bogus)); if(!val_apply_cfg(env, val_env, env->cfg)) { log_err("validator: could not apply configuration settings."); return 0; @@ -168,6 +171,7 @@ val_deinit(struct module_env* env, int id) if(!env || !env->modinfo[id]) return; val_env = (struct val_env*)env->modinfo[id]; + lock_basic_destroy(&val_env->bogus_lock); anchors_delete(env->anchors); env->anchors = NULL; key_cache_delete(val_env->kcache); diff --git a/validator/validator.h b/validator/validator.h index e514f25a6..968fcf2cd 100644 --- a/validator/validator.h +++ b/validator/validator.h @@ -108,6 +108,8 @@ struct val_env { */ size_t* nsec3_maxiter; + /** lock on bogus counter */ + lock_basic_t bogus_lock; /** number of times rrsets marked bogus */ size_t num_rrset_bogus; };