From: Wouter Wijngaards Date: Thu, 2 Aug 2007 08:07:50 +0000 (+0000) Subject: remove done and supers module interface calls. X-Git-Tag: release-0.5~167 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=630d9dbc94f7953dc724fbeb9067f0bc581edca0;p=thirdparty%2Funbound.git remove done and supers module interface calls. git-svn-id: file:///svn/unbound/trunk@474 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/configure.ac b/configure.ac index 1a71a3289..93580da71 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/daemon/worker.c b/daemon/worker.c index e326eb5b0..0ff384487 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -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); diff --git a/doc/Changelog b/doc/Changelog index 9202d6ce0..02e81e298 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -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 diff --git a/iterator/iterator.c b/iterator/iterator.c index f964d06a6..d42649f16 100644 --- a/iterator/iterator.c +++ b/iterator/iterator.c @@ -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; } diff --git a/services/mesh.c b/services/mesh.c index defa8b560..a09aab599 100644 --- a/services/mesh.c +++ b/services/mesh.c @@ -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; diff --git a/services/mesh.h b/services/mesh.h index 83d3af7d6..e7b2cd1f9 100644 --- a/services/mesh.h +++ b/services/mesh.h @@ -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. diff --git a/util/module.h b/util/module.h index be912bf00..bc9c13644 100644 --- a/util/module.h +++ b/util/module.h @@ -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.