]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
remove done and supers module interface calls.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 2 Aug 2007 08:07:50 +0000 (08:07 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 2 Aug 2007 08:07:50 +0000 (08:07 +0000)
git-svn-id: file:///svn/unbound/trunk@474 be551aaa-1e26-0410-a405-d3ace91eadb9

configure.ac
daemon/worker.c
doc/Changelog
iterator/iterator.c
services/mesh.c
services/mesh.h
util/module.h

index 1a71a32890ccc217d06e81496104b5b246be6d76..93580da7171026860310e3555cc720ff5800288e 100644 (file)
@@ -429,6 +429,8 @@ if test x_$withval != x_no; then
        fi
 fi
 
+# check for library used by libevent after 1.3c
+AC_CHECK_LIB(rt, clock_gettime)
 # check for libevent
 AC_ARG_WITH(libevent, AC_HELP_STRING([--with-libevent=pathname],
     [set path to libevent  (will check /usr/local /usr/lib /usr/pkg /usr/sfw /usr)]),
@@ -482,7 +484,6 @@ fi
 # check to see if libraries are needed for these functions.
 AC_CHECK_LIB(socket, socket)
 AC_CHECK_LIB(nsl, inet_pton)
-AC_CHECK_LIB(rt, clock_gettime)
 
 AC_FUNC_CHOWN
 AC_FUNC_FORK
index e326eb5b04f16f4f96bb21f1a6cf3363be290d88..0ff3844872260de6d8821418745dbb032892170a 100644 (file)
@@ -711,8 +711,6 @@ worker_init(struct worker* worker, struct config_file *cfg,
        worker->env.detach_subs = &mesh_detach_subs;
        worker->env.attach_sub = &mesh_attach_sub;
        worker->env.kill_sub = &mesh_state_delete;
-       worker->env.query_done = &mesh_query_done;
-       worker->env.walk_supers = &mesh_walk_supers;
        worker->env.detect_cycle = &mesh_detect_cycle;
        if(!worker->env.mesh) {
                worker_delete(worker);
index 9202d6ce07a9d04c6848f253fdd477afa1e009d8..02e81e298ff345fad07efa555e4f88efa88cb366 100644 (file)
@@ -1,5 +1,6 @@
 2 August 2007: Wouter
        - configure change for latest libevent trunk version (needs -lrt).
+       - query_done and walk_supers are moved out of module interface.
 
 1 August 2007: Wouter
        - set version to 0.5
index f964d06a65bf9b712c1c15dd0d44258d6a788eee..d42649f16fef1cc97ab8ac07fd6b58d48ff4c1dc 100644 (file)
@@ -217,10 +217,6 @@ error_response(struct module_qstate* qstate, int id, int rcode)
                ldns_lookup_by_id(ldns_rcodes, rcode)->name:"??");
        qstate->return_rcode = rcode;
        qstate->return_msg = NULL;
-       /* tell clients that we failed */
-       (*qstate->env->query_done)(qstate, rcode, NULL);
-       /* tell our parents that we failed */
-       (*qstate->env->walk_supers)(qstate, id, NULL);
        qstate->ext_state[id] = module_finished;
        return 0;
 }
@@ -1246,12 +1242,6 @@ processPrimeResponse(struct module_qstate* qstate, int id)
 
        /* This event is finished. */
        qstate->ext_state[id] = module_finished;
-
-       /* there should be no outside clients subscribed tell them to
-        * bugger off (and retry) */
-       (*qstate->env->query_done)(qstate, LDNS_RCODE_SERVFAIL, NULL);
-       /* tell interested supers that priming is done */
-       (*qstate->env->walk_supers)(qstate, id, NULL);
        return 0;
 }
 
@@ -1375,10 +1365,6 @@ processFinished(struct module_qstate* qstate, struct iter_qstate* iq,
        }
        qstate->return_rcode = LDNS_RCODE_NOERROR;
        qstate->return_msg = iq->response;
-       (*qstate->env->query_done)(qstate, LDNS_RCODE_NOERROR, 
-               iq->response->rep);
-       (*qstate->env->walk_supers)(qstate, id, NULL);
-
        return 0;
 }
 
index defa8b560dbec67aa283fc8761774793742fb001..a09aab59931de51353739ab275e724b9ce4662a6 100644 (file)
@@ -45,6 +45,7 @@
 #include "config.h"
 #include "services/mesh.h"
 #include "services/outbound_list.h"
+#include "services/cache/dns.h"
 #include "util/log.h"
 #include "util/net_help.h"
 #include "util/module.h"
@@ -211,7 +212,6 @@ mesh_state_create(struct module_env* env, struct query_info* qinfo,
        mstate->run_node = *RBTREE_NULL;
        mstate->node.key = mstate;
        mstate->run_node.key = mstate;
-       mstate->debug_flags = 0;
        mstate->reply_list = NULL;
        rbtree_init(&mstate->super_set, &mesh_state_ref_compare);
        rbtree_init(&mstate->sub_set, &mesh_state_ref_compare);
@@ -468,22 +468,16 @@ void mesh_query_done(struct module_qstate* qstate, int rcode,
 {
        struct mesh_state* m = qstate->mesh_info;
        struct mesh_reply* r;
-       log_assert(!(m->debug_flags&1)); /* not twice! */
-       m->debug_flags |= 1;
        for(r = m->reply_list; r; r = r->next) {
                mesh_send_reply(m, rcode, rep, r);
        }
 }
 
-void mesh_walk_supers(struct module_qstate* qstate, int id, 
-        void (*cb)(struct module_qstate*, int, struct module_qstate*))
+void mesh_walk_supers(struct module_qstate* qstate, int id)
 {
        struct mesh_state* m = qstate->mesh_info;
        struct mesh_area* mesh = m->s.env->mesh;
        struct mesh_state_ref* ref;
-       log_assert(!(m->debug_flags&2)); /* not twice! */
-       m->debug_flags |= 2;
-       (void)cb;
        RBTREE_FOR(ref, struct mesh_state_ref*, &qstate->mesh_info->super_set)
        {
                /* make super runnable */
@@ -542,19 +536,24 @@ void mesh_run(struct mesh_area* mesh, struct mesh_state* mstate,
 
                /* examine results */
                mstate->s.reply = NULL;
+               e = NULL;
                region_free_all(mstate->s.env->scratch);
                s = mstate->s.ext_state[mstate->s.curmod];
                verbose(VERB_ALGO, "mesh_run: %s module exit state is %s", 
                        mesh->modfunc[mstate->s.curmod]->name, strextstate(s));
                if(s == module_error || s == module_finished) {
-                       /* must have called _done and _supers */
-                       log_assert(mstate->debug_flags == 3);
-                       mesh_state_delete(&mstate->s);
+                       if(mstate->s.curmod == 0) {
+                               mesh_query_done(&mstate->s, 
+                                       mstate->s.return_rcode,
+                                       mstate->s.return_msg->rep);
+                               mesh_walk_supers(&mstate->s, mstate->s.curmod);
+                               mesh_state_delete(&mstate->s);
+                       }
+                       /* pass along the locus of control */
                }
 
                /* run more modules */
                ev = module_event_pass;
-               e = NULL;
                if(mesh->run.count > 0) {
                        /* pop random element off the runnable tree */
                        mstate = (struct mesh_state*)mesh->run.root->key;
index 83d3af7d661db8ef6223492ddbd9c003b88fced8..e7b2cd1f9289ae744e8938172ce7f7440b1f4b85 100644 (file)
@@ -111,8 +111,6 @@ struct mesh_state {
        struct module_qstate s;
        /** the list of replies to clients for the results */
        struct mesh_reply* reply_list;
-       /** debug flags */
-       int debug_flags;
        /** set of superstates (that want this state's result) 
         * contains struct mesh_state_ref* */
        rbtree_t super_set;
@@ -250,20 +248,16 @@ void mesh_query_done(struct module_qstate* qstate, int rcode,
        struct reply_info* rep);
 
 /**
- * Get a callback for the super query states that are interested in the 
+ * Call inform_super for the super query states that are interested in the 
  * results from this query state. These can then be changed for error 
  * or results.
- * Must be called befor a module can module_finished or return module_error.
- * After finishing or module error, the super query states become runnable
- * with event module_event_pass.
+ * Called when a module is module_finished or returns module_error.
+ * The super query states become runnable with event module_event_pass.
  *
  * @param qstate: the state that has results, used to find mesh state.
  * @param id: module id.
- * @param cb: callback function. Called as
- *     cb(qstate, id, super_qstate) for every super query state.
  */
-void mesh_walk_supers(struct module_qstate* qstate, int id, 
-       void (*cb)(struct module_qstate*, int, struct module_qstate*));
+void mesh_walk_supers(struct module_qstate* qstate, int id);
 
 /**
  * Delete mesh state, cleanup and also rbtrees and so on.
index be912bf0097c32034f05e10ffb486a1cb6b2a29c..bc9c13644bd024a68fd24f21db30adc06ff1e661 100644 (file)
@@ -164,40 +164,6 @@ struct module_env {
         */
        void (*kill_sub)(struct module_qstate* newq);
 
-       /**
-        * Query state is done, send messages to reply entries.
-        * Encode messages using reply entry values and the querystate 
-        * (with original qinfo), using given reply_info.
-        * Pass errcode != 0 if an error reply is needed.
-        * If no reply entries, nothing is done.
-        * Must be called before a module can module_finished or return 
-        * module_error.
-        * The module must handle the super query states itself as well.
-        * 
-        * @param qstate: used for original query info. And to find mesh info.
-        * @param rcode: if not 0 (NOERROR) an error is sent back (and 
-        *      rep ignored).
-        * @param rep: reply to encode and send back to clients.
-        */
-       void (*query_done)(struct module_qstate* qstate, int rcode,
-               struct reply_info* rep);
-
-       /**
-        * Get a callback for the super query states that are interested in the 
-        * results from this query state. These can then be changed for error 
-        * or results.
-        * Must be called befor a module can module_finished or return 
-        * module_error.  After finishing or module error, the super 
-        * query states become runnable with event module_event_pass.
-        * 
-        * @param qstate: the state that has results, used to find mesh state.
-        * @param id: module id.
-        * @param cb: callback function. Called as
-        *      cb(qstate, id, super_qstate) for every super qstate.
-        */
-       void (*walk_supers)(struct module_qstate* qstate, int id, 
-               void (*cb)(struct module_qstate*, int, struct module_qstate*));
-
        /**
         * Detect if adding a dependency for qstate on name,type,class will
         * create a dependency cycle.