]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
fptrwlist and remove oldhack with islocked param.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 4 Dec 2007 21:34:53 +0000 (21:34 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 4 Dec 2007 21:34:53 +0000 (21:34 +0000)
git-svn-id: file:///svn/unbound/trunk@805 be551aaa-1e26-0410-a405-d3ace91eadb9

17 files changed:
doc/Changelog
services/cache/infra.c
services/cache/infra.h
services/cache/rrset.c
services/cache/rrset.h
util/data/msgreply.c
util/data/msgreply.h
util/data/packed_rrset.c
util/data/packed_rrset.h
util/fptr_wlist.c
util/fptr_wlist.h
util/storage/lruhash.c
util/storage/lruhash.h
util/storage/slabhash.c
util/storage/slabhash.h
validator/val_kentry.c
validator/val_kentry.h

index d093aa8c87e3100679d98bef39a53543934ef6a4..1b06a0702d21ee07d637231077211f94088d0fad 100644 (file)
@@ -18,6 +18,8 @@
        - check return value of evtimer_add().
        - fixup lockorder in lruhash_reclaim(), building up a list of locked
          entries one at a time. Instead they are removed and unlocked.
+       - fptr_wlist for markdelfunc.
+       - removed is_locked param from lruhash delkeyfunc.
 
 3 December 2007: Wouter
        - changed checkconf/ to smallapp/ to make room for more support tools.
index d95568bf097321b69583bb8600738e4edc69d8c8..b2b6ada26d8e9ddba7fca58461ca0a5789e5e46d 100644 (file)
@@ -64,12 +64,11 @@ infra_host_compfunc(void* key1, void* key2)
 }
 
 void 
-infra_host_delkeyfunc(void* k, void* ATTR_UNUSED(arg), int il)
+infra_host_delkeyfunc(void* k, void* ATTR_UNUSED(arg))
 {
        struct infra_host_key* key = (struct infra_host_key*)k;
        if(!key)
                return;
-       if(il) { lock_rw_unlock(&key->entry.lock); }
        lock_rw_destroy(&key->entry.lock);
        free(key);
 }
@@ -309,12 +308,11 @@ infra_lame_compfunc(void* key1, void* key2)
 }
 
 void 
-infra_lame_delkeyfunc(void* k, void* ATTR_UNUSED(arg), int il)
+infra_lame_delkeyfunc(void* k, void* ATTR_UNUSED(arg))
 {
        struct infra_lame_key* key = (struct infra_lame_key*)k;
        if(!key) 
                return;
-       if(il) { lock_rw_unlock(&key->entry.lock); }
        lock_rw_destroy(&key->entry.lock);
        free(key->zonename);
        free(key);
index 9934b696f6dd797ecc6c50e245734f0e29df561b..fd5261b74734ff9edc6f461ae3fa44acdb341a24 100644 (file)
@@ -267,7 +267,7 @@ size_t infra_host_sizefunc(void* k, void* d);
 int infra_host_compfunc(void* key1, void* key2);
 
 /** delete key, and destroy the lock */
-void infra_host_delkeyfunc(void* k, void* arg, int il);
+void infra_host_delkeyfunc(void* k, void* arg);
 
 /** delete data and destroy the lameness hashtable */
 void infra_host_deldatafunc(void* d, void* arg);
@@ -280,7 +280,7 @@ size_t infra_lame_sizefunc(void* k, void* d);
 int infra_lame_compfunc(void* key1, void* key2);
 
 /** free key, lock and zonename */
-void infra_lame_delkeyfunc(void* k, void* arg, int il);
+void infra_lame_delkeyfunc(void* k, void* arg);
 
 /** free the lameness data */
 void infra_lame_deldatafunc(void* d, void* arg);
index 14399ad7200445fbe1de6f935ff3514986d1b5a3..20c97330ac2f4a41cc9a9e16d517dc77cbc3f4e9 100644 (file)
@@ -47,8 +47,7 @@
 #include "util/regional.h"
 #include "util/alloc.h"
 
-/** mark rrset to be deleted */
-static void
+void
 rrset_markdel(void* key)
 {
        struct ub_packed_rrset_key* r = (struct ub_packed_rrset_key*)key;
index 46239e06588ceb3a837aebc76852d9d970afd6de..ff3832fae00a44f4a157480419b36157d8efa729 100644 (file)
@@ -207,4 +207,7 @@ void rrset_update_sec_status(struct rrset_cache* r,
 void rrset_check_sec_status(struct rrset_cache* r, 
        struct ub_packed_rrset_key* rrset);
 
+/** mark rrset to be deleted, set id=0 */
+void rrset_markdel(void* key);
+
 #endif /* SERVICES_CACHE_RRSET_H */
index 87c94a4961d55fc3a696c2d866a8af2dfd90f6f1..7c4dab0608bf0cb93c7a262925acd08dbc3020e2 100644 (file)
@@ -543,12 +543,9 @@ msgreply_sizefunc(void* k, void* d)
 }
 
 void 
-query_entry_delete(void *k, void* ATTR_UNUSED(arg), int is_locked)
+query_entry_delete(void *k, void* ATTR_UNUSED(arg))
 {
        struct msgreply_entry* q = (struct msgreply_entry*)k;
-       if(is_locked) {
-               lock_rw_unlock(&q->entry.lock);
-       }
        lock_rw_destroy(&q->entry.lock);
        query_info_clear(&q->key);
        free(q);
index bf0ce473e3b173ffb25c3ecea163bfad646945b6..23e35e131b33928ef2f2d45b11a358f4eb564ced 100644 (file)
@@ -268,7 +268,7 @@ void query_info_clear(struct query_info* m);
 size_t msgreply_sizefunc(void* k, void* d);
 
 /** delete msgreply_entry key structure */
-void query_entry_delete(void *q, void* arg, int is_locked);
+void query_entry_delete(void *q, void* arg);
 
 /** delete reply_info data structure */
 void reply_info_delete(void* d, void* arg);
index a010fe8955f7923b4ee01504ba3b636036068e9f..52ab2567ee78423a8443c1a12ce4cc48cacab9db 100644 (file)
@@ -121,14 +121,11 @@ ub_rrset_compare(void* k1, void* k2)
 }
 
 void 
-ub_rrset_key_delete(void* key, void* userdata, int is_locked)
+ub_rrset_key_delete(void* key, void* userdata)
 {
        struct ub_packed_rrset_key* k = (struct ub_packed_rrset_key*)key;
        struct alloc_cache* a = (struct alloc_cache*)userdata;
        k->id = 0;
-       if(is_locked) {
-               lock_rw_unlock(&k->entry.lock);
-       }
        free(k->rk.dname);
        k->rk.dname = NULL;
        alloc_special_release(a, k);
index f0005277959d4ba96807707937d66b97606fd620..0a796c04a33ee0f29af920a1a9b2a88331b4a62b 100644 (file)
@@ -300,13 +300,12 @@ int rrsetdata_equal(struct packed_rrset_data* d1, struct packed_rrset_data* d2);
 
 /**
  * Old key to be deleted. RRset keys are recycled via alloc.
+ * The id is set to 0. So that other threads, after acquiring a lock always
+ * get the correct value, in this case the 0 deleted-special value.
  * @param key: struct ub_packed_rrset_key*.
  * @param userdata: alloc structure to use for recycling.
- * @param is_locked: if the key is locked, the id is set to 0 while it is
- *     still locked. So that other threads, after acquiring a lock always
- *     get the correct value, in this case the 0 deleted-special value.
  */
-void ub_rrset_key_delete(void* key, void* userdata, int is_locked);
+void ub_rrset_key_delete(void* key, void* userdata);
 
 /**
  * Old data to be deleted.
index 16286859249de68d5b89bdb225fa05fcc42314ea..abb7e29a94032150024928eb925231adf5e64996 100644 (file)
@@ -51,6 +51,7 @@
 #include "services/mesh.h"
 #include "services/localzone.h"
 #include "services/cache/infra.h"
+#include "services/cache/rrset.h"
 #include "iterator/iterator.h"
 #include "iterator/iter_donotq.h"
 #include "iterator/iter_fwd.h"
@@ -197,6 +198,14 @@ fptr_whitelist_hash_deldatafunc(lruhash_deldatafunc_t fptr)
        return 0;
 }
 
+int 
+fptr_whitelist_hash_markdelfunc(lruhash_markdelfunc_t fptr)
+{
+       if(fptr == NULL) return 1;
+       else if(fptr == &rrset_markdel) return 1;
+       return 0;
+}
+
 int 
 fptr_whitelist_modenv_send_packet(int (*fptr)(ldns_buffer* pkt,
         struct sockaddr_storage* addr, socklen_t addrlen, int timeout,
index b3cebef688eb4def3787f45af2abab64f85ba638..9f114399a65b23676b32c910e8fc19d9878f3ee2 100644 (file)
@@ -155,6 +155,14 @@ int fptr_whitelist_hash_delkeyfunc(lruhash_delkeyfunc_t fptr);
  */
 int fptr_whitelist_hash_deldatafunc(lruhash_deldatafunc_t fptr);
 
+/**
+ * Check function pointer whitelist for lruhash markdel callback values.
+ *
+ * @param fptr: function pointer to check.
+ * @return false if not in whitelist.
+ */
+int fptr_whitelist_hash_markdelfunc(lruhash_markdelfunc_t fptr);
+
 /**
  * Check function pointer whitelist for module_env send_packet callback values.
  *
index ff16aca4ec794a38b6a928da5fe8f6b9ed448a18..c1fe6e58c358df1e17501b8fabac7700f809cf4e 100644 (file)
@@ -106,7 +106,7 @@ bin_delete(struct lruhash* table, struct lruhash_bin* bin)
        while(p) {
                np = p->overflow_next;
                d = p->data;
-               (*table->delkeyfunc)(p->key, table->cb_arg, 0);
+               (*table->delkeyfunc)(p->key, table->cb_arg);
                (*table->deldatafunc)(d, table->cb_arg);
                p = np;
        }
@@ -206,7 +206,6 @@ reclaim_space(struct lruhash* table, struct lruhash_entry** list)
                lock_rw_wrlock(&d->lock);
                table->space_used -= table->sizefunc(d->key, d->data);
                if(table->markdelfunc)
-                       /* TODO fptr_wlist it */
                        (*table->markdelfunc)(d->key);
                lock_rw_unlock(&d->lock);
                lock_quick_unlock(&bin->lock);
@@ -307,6 +306,7 @@ lruhash_insert(struct lruhash* table, hashvalue_t hash,
        log_assert(fptr_whitelist_hash_delkeyfunc(table->delkeyfunc));
        log_assert(fptr_whitelist_hash_deldatafunc(table->deldatafunc));
        log_assert(fptr_whitelist_hash_compfunc(table->compfunc));
+       log_assert(fptr_whitelist_hash_markdelfunc(table->markdelfunc));
        need_size = table->sizefunc(entry->key, data);
        if(cb_arg == NULL) cb_arg = table->cb_arg;
 
@@ -327,7 +327,7 @@ lruhash_insert(struct lruhash* table, hashvalue_t hash,
                /* if so: update data - needs a writelock */
                table->space_used += need_size -
                        (*table->sizefunc)(found->key, found->data);
-               (*table->delkeyfunc)(entry->key, cb_arg, 0);
+               (*table->delkeyfunc)(entry->key, cb_arg);
                lru_touch(table, found);
                lock_rw_wrlock(&found->lock);
                (*table->deldatafunc)(found->data, cb_arg);
@@ -345,7 +345,7 @@ lruhash_insert(struct lruhash* table, hashvalue_t hash,
        while(reclaimlist) {
                struct lruhash_entry* n = reclaimlist->overflow_next;
                void* d = reclaimlist->data;
-               (*table->delkeyfunc)(reclaimlist->key, cb_arg, 0);
+               (*table->delkeyfunc)(reclaimlist->key, cb_arg);
                (*table->deldatafunc)(d, cb_arg);
                reclaimlist = n;
        }
@@ -383,6 +383,7 @@ lruhash_remove(struct lruhash* table, hashvalue_t hash, void* key)
        log_assert(fptr_whitelist_hash_delkeyfunc(table->delkeyfunc));
        log_assert(fptr_whitelist_hash_deldatafunc(table->deldatafunc));
        log_assert(fptr_whitelist_hash_compfunc(table->compfunc));
+       log_assert(fptr_whitelist_hash_markdelfunc(table->markdelfunc));
 
        lock_quick_lock(&table->lock);
        bin = &table->array[hash & table->size_mask];
@@ -400,13 +401,12 @@ lruhash_remove(struct lruhash* table, hashvalue_t hash, void* key)
        lock_quick_unlock(&table->lock);
        lock_rw_wrlock(&entry->lock);
        if(table->markdelfunc)
-               /* TODO fptr wlist it */
                (*table->markdelfunc)(entry->key);
        lock_rw_unlock(&entry->lock);
        lock_quick_unlock(&bin->lock);
        /* finish removal */
        d = entry->data;
-       (*table->delkeyfunc)(entry->key, table->cb_arg, 0);
+       (*table->delkeyfunc)(entry->key, table->cb_arg);
        (*table->deldatafunc)(d, table->cb_arg);
 }
 
@@ -423,10 +423,9 @@ bin_clear(struct lruhash* table, struct lruhash_bin* bin)
                np = p->overflow_next;
                d = p->data;
                if(table->markdelfunc)
-                       /* TODO fptr wlist it */
                        (*table->markdelfunc)(p->key);
                lock_rw_unlock(&p->lock);
-               (*table->delkeyfunc)(p->key, table->cb_arg, 0);
+               (*table->delkeyfunc)(p->key, table->cb_arg);
                (*table->deldatafunc)(d, table->cb_arg);
                p = np;
        }
@@ -442,6 +441,7 @@ lruhash_clear(struct lruhash* table)
                return;
        log_assert(fptr_whitelist_hash_delkeyfunc(table->delkeyfunc));
        log_assert(fptr_whitelist_hash_deldatafunc(table->deldatafunc));
+       log_assert(fptr_whitelist_hash_markdelfunc(table->markdelfunc));
 
        lock_quick_lock(&table->lock);
        for(i=0; i<table->size; i++) {
index 7a4084a57cddce3d74b6d799e3e892d5553668d1..8d3ebe448c587c04c86c9e4fd503c33f2941f082 100644 (file)
@@ -130,13 +130,9 @@ typedef size_t (*lruhash_sizefunc_t)(void*, void*);
 typedef int (*lruhash_compfunc_t)(void*, void*);
 
 /** old keys are deleted. 
- * If is_locked is set, then the routine must unlock the item before deletion.
- * If is_locked is not set, then this item is not locked. This allows the 
- * routine to perform operations within the critical region of the lock 
- * of the key. The critical region has been locked before the delete happened.
- * The RRset type has to revoke its ID number inside the critical region.
- * This function is called: func(key, userarg, is_locked) */
-typedef void (*lruhash_delkeyfunc_t)(void*, void*, int);
+ * The RRset type has to revoke its ID number, markdel() is used first.
+ * This function is called: func(key, userarg) */
+typedef void (*lruhash_delkeyfunc_t)(void*, void*);
 
 /** old data is deleted. This function is called: func(data, userarg). */
 typedef void (*lruhash_deldatafunc_t)(void*, void*);
index 71292d495388bd88bc5909fcbcfb68beb5394a16..314763119e8843bcff30bf516c6fbbf1adc2321f 100644 (file)
@@ -192,9 +192,8 @@ int test_slabhash_compfunc(void* key1, void* key2)
        return -1;
 }
 
-void test_slabhash_delkey(void* key, void* ATTR_UNUSED(arg), int l)
+void test_slabhash_delkey(void* key, void* ATTR_UNUSED(arg))
 {
-       if(l) { lock_rw_unlock(&((struct slabhash_testkey*)key)->entry.lock); }
        delkey((struct slabhash_testkey*)key);
 }
 
index 6fd4efb818026c7487a171f4d79a81e7ce9e888c..87e283e62e98fe447bd2a4c23c0f0509530296b5 100644 (file)
@@ -193,7 +193,7 @@ size_t test_slabhash_sizefunc(void*, void*);
 /** test comparefunc for lruhash */
 int test_slabhash_compfunc(void*, void*);
 /** test delkey for lruhash */
-void test_slabhash_delkey(void*, void*, int);
+void test_slabhash_delkey(void*, void*);
 /** test deldata for lruhash */
 void test_slabhash_deldata(void*, void*);
 /* --- end test representation --- */
index b4c871fff92289c9f2db5b1ab6cfcf2bf558c2b2..de846c12a0834ab92c39f1ad985d1c83b1c6f3b3 100644 (file)
@@ -72,14 +72,11 @@ key_entry_compfunc(void* k1, void* k2)
 }
 
 void 
-key_entry_delkeyfunc(void* key, void* ATTR_UNUSED(userarg), int islocked)
+key_entry_delkeyfunc(void* key, void* ATTR_UNUSED(userarg))
 {
        struct key_entry_key* kk = (struct key_entry_key*)key;
        if(!key)
                return;
-       if(islocked) {
-               lock_rw_unlock(&kk->entry.lock);
-       }
        free(kk->name);
        free(kk);
 }
index bda29113e2772f43ec4496b6a99780b1e6d95060..2b0a12f5a55c735f3f3fb998443bc414a1140e1f 100644 (file)
@@ -91,7 +91,7 @@ size_t key_entry_sizefunc(void* key, void* data);
 int key_entry_compfunc(void* k1, void* k2);
 
 /** function for lruhash operation */
-void key_entry_delkeyfunc(void* key, void* userarg, int islocked);
+void key_entry_delkeyfunc(void* key, void* userarg);
 
 /** function for lruhash operation */
 void key_entry_deldatafunc(void* data, void* userarg);