mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
- Fix forward-zone memory, uses malloc and frees original root dp.
git-svn-id: file:///svn/unbound/trunk@2621 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
db6cd0a635
commit
7a58fdcebc
3 changed files with 23 additions and 12 deletions
|
|
@ -1389,9 +1389,6 @@ do_forward(SSL* ssl, struct worker* worker, char* args)
|
|||
* the actual mesh is not running, so we can freely edit it. */
|
||||
/* delete all the existing queries first */
|
||||
mesh_delete_all(worker->env.mesh);
|
||||
/* reset the fwd structure ; the cfg is unchanged (shared by threads)*/
|
||||
/* this reset frees up memory */
|
||||
forwards_apply_cfg(fwd, worker->env.cfg);
|
||||
if(strcmp(args, "off") == 0) {
|
||||
forwards_delete_zone(fwd, LDNS_RR_CLASS_IN, root);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
15 February 2012: Wouter
|
||||
- Fix forward-zone memory, uses malloc and frees original root dp.
|
||||
|
||||
14 February 2012: Wouter
|
||||
- Fix sticky NS (ghost domain problem) if prefetch is yes.
|
||||
- iter forwards uses malloc inside for more dynamicity.
|
||||
|
|
|
|||
|
|
@ -432,9 +432,25 @@ forwards_get_mem(struct iter_forwards* fwd)
|
|||
return s;
|
||||
}
|
||||
|
||||
static struct iter_forward_zone*
|
||||
fwd_zone_find(struct iter_forwards* fwd, uint16_t c, uint8_t* nm)
|
||||
{
|
||||
struct iter_forward_zone key;
|
||||
key.node.key = &key;
|
||||
key.dclass = c;
|
||||
key.name = nm;
|
||||
key.namelabs = dname_count_size_labels(nm, &key.namelen);
|
||||
return (struct iter_forward_zone*)rbtree_search(fwd->tree, &key);
|
||||
}
|
||||
|
||||
int
|
||||
forwards_add_zone(struct iter_forwards* fwd, uint16_t c, struct delegpt* dp)
|
||||
{
|
||||
struct iter_forward_zone *z;
|
||||
if((z=fwd_zone_find(fwd, c, dp->name)) != NULL) {
|
||||
fwd_zone_free(z);
|
||||
(void)rbtree_delete(fwd->tree, &z->node);
|
||||
}
|
||||
if(!forwards_insert(fwd, c, dp))
|
||||
return 0;
|
||||
fwd_init_parents(fwd);
|
||||
|
|
@ -444,16 +460,11 @@ forwards_add_zone(struct iter_forwards* fwd, uint16_t c, struct delegpt* dp)
|
|||
void
|
||||
forwards_delete_zone(struct iter_forwards* fwd, uint16_t c, uint8_t* nm)
|
||||
{
|
||||
rbnode_t* n;
|
||||
struct iter_forward_zone key;
|
||||
key.node.key = &key;
|
||||
key.dclass = c;
|
||||
key.name = nm;
|
||||
key.namelabs = dname_count_size_labels(nm, &key.namelen);
|
||||
if(!(n=rbtree_search(fwd->tree, &key)))
|
||||
struct iter_forward_zone *z;
|
||||
if(!(z=fwd_zone_find(fwd, c, nm)))
|
||||
return; /* nothing to do */
|
||||
fwd_zone_free((struct iter_forward_zone*)n);
|
||||
(void)rbtree_delete(fwd->tree, &key);
|
||||
fwd_zone_free(z);
|
||||
(void)rbtree_delete(fwd->tree, &z->node);
|
||||
fwd_init_parents(fwd);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue