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)]),
# 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
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);
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
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;
}
/* 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;
}
}
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;
}
#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"
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);
{
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 */
/* 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;
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;
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.
*/
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.