mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-27 02:00:18 -05:00
- Fix to lock and release once in mesh_serve_expired_lookup.
This commit is contained in:
parent
18ea62e369
commit
4089147351
2 changed files with 8 additions and 13 deletions
|
|
@ -7,6 +7,7 @@
|
||||||
after serve_stale commit.
|
after serve_stale commit.
|
||||||
- Fix to create and destroy rpz_lock in auth_zones structure.
|
- Fix to create and destroy rpz_lock in auth_zones structure.
|
||||||
- Fix to lock zone before adding rpz qname trigger.
|
- Fix to lock zone before adding rpz qname trigger.
|
||||||
|
- Fix to lock and release once in mesh_serve_expired_lookup.
|
||||||
|
|
||||||
5 February 2020: George
|
5 February 2020: George
|
||||||
- Added serve-stale functionality as described in
|
- Added serve-stale functionality as described in
|
||||||
|
|
|
||||||
|
|
@ -357,6 +357,7 @@ mesh_serve_expired_lookup(struct module_qstate* qstate,
|
||||||
struct reply_info* rep, *data;
|
struct reply_info* rep, *data;
|
||||||
struct msgreply_entry* key;
|
struct msgreply_entry* key;
|
||||||
time_t timenow = *qstate->env->now;
|
time_t timenow = *qstate->env->now;
|
||||||
|
time_t time_control = timenow;
|
||||||
int must_validate = (!(qstate->query_flags&BIT_CD)
|
int must_validate = (!(qstate->query_flags&BIT_CD)
|
||||||
|| qstate->env->cfg->ignore_cd) && qstate->env->need_to_validate;
|
|| qstate->env->cfg->ignore_cd) && qstate->env->need_to_validate;
|
||||||
/* Lookup cache */
|
/* Lookup cache */
|
||||||
|
|
@ -371,8 +372,7 @@ mesh_serve_expired_lookup(struct module_qstate* qstate,
|
||||||
if(qstate->env->cfg->serve_expired_ttl &&
|
if(qstate->env->cfg->serve_expired_ttl &&
|
||||||
rep->serve_expired_ttl < timenow)
|
rep->serve_expired_ttl < timenow)
|
||||||
goto bail_out;
|
goto bail_out;
|
||||||
if(!rrset_array_lock(rep->ref, rep->rrset_count, 0))
|
time_control = timenow;
|
||||||
goto bail_out;
|
|
||||||
} else {
|
} else {
|
||||||
/* the rrsets may have been updated in the meantime.
|
/* the rrsets may have been updated in the meantime.
|
||||||
* we will refetch the message format from the
|
* we will refetch the message format from the
|
||||||
|
|
@ -381,8 +381,7 @@ mesh_serve_expired_lookup(struct module_qstate* qstate,
|
||||||
goto bail_out;
|
goto bail_out;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!rrset_array_lock(rep->ref, rep->rrset_count, timenow))
|
time_control = timenow;
|
||||||
goto bail_out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check CNAME chain (if any)
|
/* Check CNAME chain (if any)
|
||||||
|
|
@ -395,30 +394,25 @@ mesh_serve_expired_lookup(struct module_qstate* qstate,
|
||||||
if(must_validate && (rep->security == sec_status_bogus ||
|
if(must_validate && (rep->security == sec_status_bogus ||
|
||||||
rep->security == sec_status_secure_sentinel_fail)) {
|
rep->security == sec_status_secure_sentinel_fail)) {
|
||||||
verbose(VERB_ALGO, "Serve expired: bogus answer found in cache");
|
verbose(VERB_ALGO, "Serve expired: bogus answer found in cache");
|
||||||
goto bail_out_rrset;
|
goto bail_out;
|
||||||
} else if(rep->security == sec_status_unchecked && must_validate) {
|
} else if(rep->security == sec_status_unchecked && must_validate) {
|
||||||
verbose(VERB_ALGO, "Serve expired: unchecked entry needs "
|
verbose(VERB_ALGO, "Serve expired: unchecked entry needs "
|
||||||
"validation");
|
"validation");
|
||||||
goto bail_out_rrset; /* need to validate cache entry first */
|
goto bail_out; /* need to validate cache entry first */
|
||||||
} else if(rep->security == sec_status_secure &&
|
} else if(rep->security == sec_status_secure &&
|
||||||
!reply_all_rrsets_secure(rep) && must_validate) {
|
!reply_all_rrsets_secure(rep) && must_validate) {
|
||||||
verbose(VERB_ALGO, "Serve expired: secure entry"
|
verbose(VERB_ALGO, "Serve expired: secure entry"
|
||||||
" changed status");
|
" changed status");
|
||||||
goto bail_out_rrset; /* rrset changed, re-verify */
|
goto bail_out; /* rrset changed, re-verify */
|
||||||
}
|
}
|
||||||
|
|
||||||
key = (struct msgreply_entry*)e->key;
|
key = (struct msgreply_entry*)e->key;
|
||||||
data = (struct reply_info*)e->data;
|
data = (struct reply_info*)e->data;
|
||||||
msg = tomsg(qstate->env, &key->key, data, qstate->region, timenow,
|
msg = tomsg(qstate->env, &key->key, data, qstate->region, time_control,
|
||||||
qstate->env->cfg->serve_expired, qstate->env->scratch);
|
qstate->env->cfg->serve_expired, qstate->env->scratch);
|
||||||
rrset_array_unlock_touch(qstate->env->rrset_cache,
|
|
||||||
qstate->region, rep->ref, rep->rrset_count);
|
|
||||||
lock_rw_unlock(&e->lock);
|
lock_rw_unlock(&e->lock);
|
||||||
return msg;
|
return msg;
|
||||||
|
|
||||||
bail_out_rrset:
|
|
||||||
rrset_array_unlock_touch(qstate->env->rrset_cache,
|
|
||||||
qstate->region, rep->ref, rep->rrset_count);
|
|
||||||
bail_out:
|
bail_out:
|
||||||
lock_rw_unlock(&e->lock);
|
lock_rw_unlock(&e->lock);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue