struct ctx_query*
context_new(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass,
- void* cb, void* cbarg)
+ ub_callback_type cb, ub_event_callback_type cb_event, void* cbarg)
{
struct ctx_query* q = (struct ctx_query*)calloc(1, sizeof(*q));
if(!q) return NULL;
}
lock_basic_unlock(&ctx->cfglock);
q->node.key = &q->querynum;
- q->async = (cb != NULL);
+ q->async = (cb != NULL && cb_event != NULL);
q->cb = cb;
+ q->cb_event = cb_event;
q->cb_arg = cbarg;
q->res = (struct ub_result*)calloc(1, sizeof(*q->res));
if(!q->res) {
#include "util/rbtree.h"
#include "services/modstack.h"
#include "libunbound/unbound.h"
+#include "libunbound/unbound-event.h"
#include "util/data/packed_rrset.h"
struct libworker;
struct tube;
/** was this query cancelled (for bg worker) */
int cancelled;
- /** for async query, the callback function of type ub_callback_type
- * for event callbacks the type is ub_event_callback_type */
- void* cb;
+ /** for async query, the callback function of type ub_callback_type */
+ ub_callback_type cb;
+ /** for event callbacks the type is ub_event_callback_type */
+ ub_event_callback_type cb_event;
/** for async query, the callback user arg */
void* cb_arg;
* @param rrtype: type
* @param rrclass: class
* @param cb: callback for async, or NULL for sync.
+ * @param cb_event: event callback for async, or NULL for sync.
* @param cbarg: user arg for async queries.
* @return new ctx_query or NULL for malloc failure.
*/
struct ctx_query* context_new(struct ub_ctx* ctx, const char* name, int rrtype,
- int rrclass, void* cb, void* cbarg);
+ int rrclass, ub_callback_type cb, ub_event_callback_type cb_event,
+ void* cbarg);
/**
* Get a new alloc. Creates a new one or uses a cached one.
*cb = NULL;
*cbarg = NULL;
} else {
- *cb = (ub_callback_type)q->cb;
+ *cb = q->cb;
*cbarg = q->cb_arg;
}
if(*err) {
}
/* create new ctx_query and attempt to add to the list */
lock_basic_unlock(&ctx->cfglock);
- q = context_new(ctx, name, rrtype, rrclass, NULL, NULL);
+ q = context_new(ctx, name, rrtype, rrclass, NULL, NULL, NULL);
if(!q)
return UB_NOMEM;
/* become a resolver thread for a bit */
ub_comm_base_now(ctx->event_worker->base);
/* create new ctx_query and attempt to add to the list */
- q = context_new(ctx, name, rrtype, rrclass, callback, mydata);
+ q = context_new(ctx, name, rrtype, rrclass, NULL, callback, mydata);
if(!q)
return UB_NOMEM;
}
/* create new ctx_query and attempt to add to the list */
- q = context_new(ctx, name, rrtype, rrclass, callback, mydata);
+ q = context_new(ctx, name, rrtype, rrclass, callback, NULL, mydata);
if(!q)
return UB_NOMEM;
enum sec_status s, char* why_bogus)
{
struct ctx_query* q = (struct ctx_query*)arg;
- ub_event_callback_type cb = (ub_event_callback_type)q->cb;
+ ub_event_callback_type cb = q->cb_event;
void* cb_arg = q->cb_arg;
int cancelled = q->cancelled;