- 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.
}
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);
}
}
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);
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);
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);
#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;
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 */
}
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);
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);
}
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);
/**
* 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.
#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"
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,
*/
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.
*
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;
}
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);
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;
/* 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);
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;
}
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];
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);
}
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;
}
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++) {
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*);
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);
}
/** 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 --- */
}
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);
}
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);