]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
threadsafe rrset counter.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 17 Sep 2008 07:13:31 +0000 (07:13 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 17 Sep 2008 07:13:31 +0000 (07:13 +0000)
git-svn-id: file:///svn/unbound/trunk@1240 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/stats.c
doc/Changelog
validator/val_utils.c
validator/validator.c
validator/validator.h

index d62411403ebaf26df8c23b2a22ff054faf0ba58f..89f9e5fd8d95a3baac3c5a307942183dbcc3b46b 100644 (file)
@@ -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;
 }
 
index 0f9afb4ba44f6c3770879b2e57d34a214b920be9..8f7424d410573eecb1fc25eb8e9b7d908a2c2b48 100644 (file)
@@ -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.
index 79351a8b0cfae084b12976b67c56d5cb239023c2..14483969561e28aa544dfcbe9a56455d12b3103c 100644 (file)
@@ -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);
index ec7f1241add75034f20ef5f9d0061c1d8de3860a..1f7d9c07ec6f6b7056569a2e3ab0234d0cbaa59e 100644 (file)
@@ -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);
index e514f25a63076089109888c1d8e23401d8559683..968fcf2cd001c4d1508548fba166c2e9f85de8ae 100644 (file)
@@ -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;
 };