]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
cache lameness, set reply properly.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 4 Jun 2007 11:52:10 +0000 (11:52 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 4 Jun 2007 11:52:10 +0000 (11:52 +0000)
git-svn-id: file:///svn/unbound/trunk@363 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/worker.c
doc/Changelog
iterator/iterator.c

index 4af4e7c6b1f1992f616e93855bbfbc9389f72322..33003e1f808a8d4465d1795160bcdc53d90df98f 100644 (file)
@@ -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;
 }
 
index a950385986528790f32976696b7b4bef8814a60f..ebb54cba0bd6ce78a5f4f7aef33edcfd15db4ad5 100644 (file)
@@ -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
index 90d6d3fff5e81ca78dba9ed489c76127e29c4c58..581716e458561427fbd5afff7c42fb43b06b5daf 100644 (file)
@@ -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