locked = 1;
}
- if (resolution->step == RSLV_STEP_RUNNING) {
- ret = ACT_RET_YIELD;
- goto end;
- }
+ if (resolution->step == RSLV_STEP_RUNNING)
+ goto yield;
if (resolution->step == RSLV_STEP_NONE) {
/* We update the variable only if we have a valid response. */
if (resolution->status == RSLV_STATUS_VALID) {
}
}
- free(s->dns_ctx.hostname_dn); s->dns_ctx.hostname_dn = NULL;
- s->dns_ctx.hostname_dn_len = 0;
- dns_unlink_resolution(s->dns_ctx.dns_requester);
-
- pool_free(dns_requester_pool, s->dns_ctx.dns_requester);
- s->dns_ctx.dns_requester = NULL;
-
- goto end;
+ goto release_requester;
}
/* need to configure and start a new DNS resolution */
/* Check if there is a fresh enough response in the cache of our associated resolution */
req = s->dns_ctx.dns_requester;
- if (!req || !req->resolution) {
- dns_trigger_resolution(s->dns_ctx.dns_requester);
- ret = ACT_RET_YIELD;
- goto end;
- }
+ if (!req || !req->resolution)
+ goto release_requester; /* on error, ignore the action */
res = req->resolution;
exp = tick_add(res->last_resolution, resolvers->hold.valid);
if (resolvers->t && res->status == RSLV_STATUS_VALID && tick_isset(res->last_resolution)
- && !tick_is_expired(exp, now_ms)) {
+ && !tick_is_expired(exp, now_ms)) {
goto use_cache;
}
dns_trigger_resolution(s->dns_ctx.dns_requester);
+
+ yield:
+ if (flags & ACT_OPT_FINAL)
+ goto release_requester;
ret = ACT_RET_YIELD;
end:
if (locked)
HA_SPIN_UNLOCK(DNS_LOCK, &resolvers->lock);
return ret;
+
+ release_requester:
+ free(s->dns_ctx.hostname_dn);
+ s->dns_ctx.hostname_dn = NULL;
+ s->dns_ctx.hostname_dn_len = 0;
+ if (s->dns_ctx.dns_requester) {
+ dns_unlink_resolution(s->dns_ctx.dns_requester);
+ pool_free(dns_requester_pool, s->dns_ctx.dns_requester);
+ s->dns_ctx.dns_requester = NULL;
+ }
+ goto end;
}
static void release_dns_action(struct act_rule *rule)