]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
always do an insert on change of data. Else lruhash size is
authorYuri Schaeffer <yuri@nlnetlabs.nl>
Wed, 16 Oct 2013 14:42:23 +0000 (14:42 +0000)
committerYuri Schaeffer <yuri@nlnetlabs.nl>
Wed, 16 Oct 2013 14:42:23 +0000 (14:42 +0000)
not calculated or managed. lruhash now supports updating
with the same data and the same key.

git-svn-id: file:///svn/unbound/branches/edns-subnet@2986 be551aaa-1e26-0410-a405-d3ace91eadb9

edns-subnet/addrtree.c
edns-subnet/subnetmod.c
util/storage/lruhash.c

index 7a62acc9e2ace6a0de66d457ccd22278fc4ff9d6..7e47f9ac163122000b6cd1df50b151c864f0888e 100644 (file)
@@ -448,7 +448,6 @@ addrtree_find(struct addrtree *tree, const addrkey_t *addr,
                parent_node = node;
                depth = edge->len;
                node = edge->node;
-               
        }
 }
 
index 7954338caa13f332696495535b6a3d26a0b172b9..ddc0fa103a12945793e5e305e1808083f5d1431a 100644 (file)
@@ -178,7 +178,6 @@ void update_cache(struct module_qstate *qstate, int id)
                        log_err("malloc failed");
                        return;
                }
-               slabhash_insert(subnet_msg_cache, h, lru_entry, lru_entry->data, NULL);
        }
        /** Step 2, find the correct tree */
        if (!(tree = get_tree(lru_entry->data, edns, qstate->env))) {
@@ -193,7 +192,9 @@ void update_cache(struct module_qstate *qstate, int id)
                edns->subnet_source_mask, 
                qstate->edns_server_in.subnet_scope_mask, rep, rep->ttl + *qstate->env->now,
                *qstate->env->now);
-       if (acquired_lock) lock_rw_unlock(&lru_entry->lock);
+       if (acquired_lock)
+               lock_rw_unlock(&lru_entry->lock);
+       slabhash_insert(subnet_msg_cache, h, lru_entry, lru_entry->data, NULL);
 }
 
 
index c22278dda1e85dc7e750a5834155b14745a88068..560cf9015d51d75178ec8a97d7e18b5b02930a30 100644 (file)
@@ -327,11 +327,15 @@ 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);
+               if (found->key != entry->key) {
+                       (*table->delkeyfunc)(entry->key, cb_arg);
+               }
                lru_touch(table, found);
                lock_rw_wrlock(&found->lock);
-               (*table->deldatafunc)(found->data, cb_arg);
-               found->data = data;
+               if (found->data != data) {
+                       (*table->deldatafunc)(found->data, cb_arg);
+                       found->data = data;
+               }
                lock_rw_unlock(&found->lock);
        }
        lock_quick_unlock(&bin->lock);