From: Wouter Wijngaards Date: Mon, 4 Jun 2007 11:52:10 +0000 (+0000) Subject: cache lameness, set reply properly. X-Git-Tag: release-0.4~103 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2102aa0a3a917d0bd09b9ae72148c4e6ce215ab7;p=thirdparty%2Funbound.git cache lameness, set reply properly. git-svn-id: file:///svn/unbound/trunk@363 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/daemon/worker.c b/daemon/worker.c index 4af4e7c6b..33003e1f8 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -214,6 +214,7 @@ worker_process_query(struct worker* worker, struct work_query* w, (*worker->daemon->modfunc[qstate->curmod]->operate)(qstate, event, qstate->curmod, entry); region_free_all(worker->scratchpad); + qstate->reply = NULL; s = qstate->ext_state[qstate->curmod]; /* examine results, start further modules, etc. */ if(s == module_wait_subquery) { @@ -287,7 +288,6 @@ worker_handle_reply(struct comm_point* c, void* arg, int error, if(error != 0) { worker_process_query(worker, w, &w->state, module_event_timeout, NULL); - w->state.reply = NULL; return 0; } /* sanity check. */ @@ -299,11 +299,9 @@ worker_handle_reply(struct comm_point* c, void* arg, int error, * never arrived. */ worker_process_query(worker, w, &w->state, module_event_timeout, NULL); - w->state.reply = NULL; return 0; } worker_process_query(worker, w, &w->state, module_event_reply, NULL); - w->state.reply = NULL; return 0; } @@ -316,11 +314,10 @@ worker_handle_service_reply(struct comm_point* c, void* arg, int error, struct work_query* w = e->qstate->work_info; struct worker* worker = w->state.env->worker; - w->state.reply = reply_info; + e->qstate->reply = reply_info; if(error != 0) { worker_process_query(worker, w, e->qstate, module_event_timeout, e); - w->state.reply = NULL; return 0; } /* sanity check. */ @@ -332,11 +329,9 @@ worker_handle_service_reply(struct comm_point* c, void* arg, int error, * never arrived. */ worker_process_query(worker, w, e->qstate, module_event_timeout, e); - w->state.reply = NULL; return 0; } worker_process_query(worker, w, e->qstate, module_event_reply, e); - w->state.reply = NULL; return 0; } diff --git a/doc/Changelog b/doc/Changelog index a95038598..ebb54cba0 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,6 +1,9 @@ 4 June 2007: Wouter - random selection of equally preferred nameserver targets. - reply info copy routine. Reuses existing code. + - cache lameness in response handling. + - do not touch qstate after worker_process_query because it may have + been deleted by that routine. 1 June 2007: Wouter - normalize incoming messages. Like unbound-java, with CNAME chain diff --git a/iterator/iterator.c b/iterator/iterator.c index 90d6d3fff..581716e45 100644 --- a/iterator/iterator.c +++ b/iterator/iterator.c @@ -48,6 +48,7 @@ #include "iterator/iter_resptype.h" #include "iterator/iter_scrub.h" #include "services/cache/dns.h" +#include "services/cache/infra.h" #include "util/module.h" #include "util/netevent.h" #include "util/net_help.h" @@ -1091,6 +1092,7 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, verbose(VERB_ALGO, "query response was timeout"); return next_state(qstate, iq, QUERYTARGETS_STATE); } + log_assert(qstate->reply); /* need addr for lameness cache */ type = response_type_from_server(iq->response, &qstate->qinfo, iq->dp); if(type == RESPONSE_TYPE_ANSWER) { /* ANSWER type responses terminate the query algorithm, @@ -1173,8 +1175,11 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq, return next_state(qstate, iq, INIT_REQUEST_STATE); } else if(type == RESPONSE_TYPE_LAME) { /* Cache the LAMEness. */ - /* TODO mark addr, dp->name, as lame */ verbose(VERB_ALGO, "query response was LAME"); + if(!infra_set_lame(qstate->env->infra_cache, + &qstate->reply->addr, qstate->reply->addrlen, + iq->dp->name, iq->dp->namelen, time(NULL))) + log_err("mark host lame: out of memory"); } else if(type == RESPONSE_TYPE_THROWAWAY) { /* LAME and THROWAWAY responses are handled the same way. * In this case, the event is just sent directly back to