mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-24 00:29:58 -05:00
- Fix for iter_dec_attempts that could cause a hang, part of
capsforid and qname minimisation, depending on the settings.
This commit is contained in:
parent
5f423906de
commit
2791ccbe02
3 changed files with 65 additions and 2 deletions
|
|
@ -321,6 +321,45 @@ void delegpt_log(enum verbosity_value v, struct delegpt* dp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
delegpt_addr_on_result_list(struct delegpt* dp, struct delegpt_addr* find)
|
||||||
|
{
|
||||||
|
struct delegpt_addr* a = dp->result_list;
|
||||||
|
while(a) {
|
||||||
|
if(a == find)
|
||||||
|
return 1;
|
||||||
|
a = a->next_result;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
delegpt_usable_list_remove_addr(struct delegpt* dp, struct delegpt_addr* del)
|
||||||
|
{
|
||||||
|
struct delegpt_addr* usa = dp->usable_list, *prev = NULL;
|
||||||
|
while(usa) {
|
||||||
|
if(usa == del) {
|
||||||
|
/* snip off the usable list */
|
||||||
|
if(prev)
|
||||||
|
prev->next_usable = usa->next_usable;
|
||||||
|
else dp->usable_list = usa->next_usable;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
prev = usa;
|
||||||
|
usa = usa->next_usable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
delegpt_add_to_result_list(struct delegpt* dp, struct delegpt_addr* a)
|
||||||
|
{
|
||||||
|
if(delegpt_addr_on_result_list(dp, a))
|
||||||
|
return;
|
||||||
|
delegpt_usable_list_remove_addr(dp, a);
|
||||||
|
a->next_result = dp->result_list;
|
||||||
|
dp->result_list = a;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
delegpt_add_unused_targets(struct delegpt* dp)
|
delegpt_add_unused_targets(struct delegpt* dp)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -457,4 +457,29 @@ int delegpt_add_target_mlc(struct delegpt* dp, uint8_t* name, size_t namelen,
|
||||||
/** get memory in use by dp */
|
/** get memory in use by dp */
|
||||||
size_t delegpt_get_mem(struct delegpt* dp);
|
size_t delegpt_get_mem(struct delegpt* dp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See if the addr is on the result list.
|
||||||
|
* @param dp: delegation point.
|
||||||
|
* @param find: the pointer is searched for on the result list.
|
||||||
|
* @return 1 if found, 0 if not found.
|
||||||
|
*/
|
||||||
|
int delegpt_addr_on_result_list(struct delegpt* dp, struct delegpt_addr* find);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the addr from the usable list.
|
||||||
|
* @param dp: the delegation point.
|
||||||
|
* @param del: the addr to remove from the list, the pointer is searched for.
|
||||||
|
*/
|
||||||
|
void delegpt_usable_list_remove_addr(struct delegpt* dp,
|
||||||
|
struct delegpt_addr* del);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the delegpt_addr back to the result list, if it is not already on
|
||||||
|
* the result list. Also removes it from the usable list.
|
||||||
|
* @param dp: delegation point.
|
||||||
|
* @param a: addr to add, nothing happens if it is already on the result list.
|
||||||
|
* It is removed from the usable list.
|
||||||
|
*/
|
||||||
|
void delegpt_add_to_result_list(struct delegpt* dp, struct delegpt_addr* a);
|
||||||
|
|
||||||
#endif /* ITERATOR_ITER_DELEGPT_H */
|
#endif /* ITERATOR_ITER_DELEGPT_H */
|
||||||
|
|
|
||||||
|
|
@ -1346,8 +1346,7 @@ void iter_dec_attempts(struct delegpt* dp, int d, int outbound_msg_retry)
|
||||||
for(a=dp->target_list; a; a = a->next_target) {
|
for(a=dp->target_list; a; a = a->next_target) {
|
||||||
if(a->attempts >= outbound_msg_retry) {
|
if(a->attempts >= outbound_msg_retry) {
|
||||||
/* add back to result list */
|
/* add back to result list */
|
||||||
a->next_result = dp->result_list;
|
delegpt_add_to_result_list(dp, a);
|
||||||
dp->result_list = a;
|
|
||||||
}
|
}
|
||||||
if(a->attempts > d)
|
if(a->attempts > d)
|
||||||
a->attempts -= d;
|
a->attempts -= d;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue