{
struct ctx_query* q = (struct ctx_query*)calloc(1, sizeof(*q));
if(!q) return NULL;
+ lock_basic_lock(&ctx->cfglock);
if(!find_id(ctx, &q->querynum)) {
+ lock_basic_unlock(&ctx->cfglock);
free(q);
return NULL;
}
+ lock_basic_unlock(&ctx->cfglock);
q->node.key = &q->querynum;
q->async = (cb != NULL);
q->cb = cb;
q->res->qclass = rrclass;
/* add to query list */
+ lock_basic_lock(&ctx->cfglock);
if(q->async)
ctx->num_async ++;
(void)rbtree_insert(&ctx->queries, &q->node);
+ lock_basic_unlock(&ctx->cfglock);
return q;
}
}
}
/* create new ctx_query and attempt to add to the list */
- q = context_new(ctx, name, rrtype, rrclass, NULL, NULL);
lock_basic_unlock(&ctx->cfglock);
+ q = context_new(ctx, name, rrtype, rrclass, NULL, NULL);
if(!q)
return UB_NOMEM;
/* become a resolver thread for a bit */
}
}
/* create new ctx_query and attempt to add to the list */
- q = context_new(ctx, name, rrtype, rrclass, callback, mydata);
lock_basic_unlock(&ctx->cfglock);
+ q = context_new(ctx, name, rrtype, rrclass, callback, mydata);
if(!q)
return UB_NOMEM;
/* TODO write over pipe to background worker */