free(msg);
}
lock_basic_unlock(&ctx->rrpipe_lock);
+
+ /* if bg worker is a thread, wait for it to exit, so that all
+ * resources are really gone. */
+ lock_basic_lock(&ctx->cfglock);
+ if(ctx->dothread) {
+ lock_basic_unlock(&ctx->cfglock);
+ ub_thread_join(ctx->bg_tid);
+ } else {
+ lock_basic_unlock(&ctx->cfglock);
+ }
+ }
+ else {
+ lock_basic_unlock(&ctx->cfglock);
}
- else lock_basic_unlock(&ctx->cfglock);
+
modstack_desetup(&ctx->mods, ctx->env);
a = ctx->alloc_list;
lock_basic_unlock(&ctx->cfglock);
return r;
}
- } else lock_basic_unlock(&ctx->cfglock);
+ } else {
+ lock_basic_unlock(&ctx->cfglock);
+ }
/* 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);
lock_basic_lock(&ctx->qqpipe_lock);
- libworker_write_msg(ctx->qqpipe[1], msg, len, 0);
+ if(!libworker_write_msg(ctx->qqpipe[1], msg, len, 0)) {
+ lock_basic_unlock(&ctx->qqpipe_lock);
+ free(msg);
+ return UB_PIPE;
+ }
lock_basic_unlock(&ctx->qqpipe_lock);
free(msg);
return UB_NOERROR;
/* send cancel to background worker */
lock_basic_lock(&ctx->qqpipe_lock);
- libworker_write_msg(ctx->qqpipe[1], msg, len, 0);
+ if(!libworker_write_msg(ctx->qqpipe[1], msg, len, 0)) {
+ lock_basic_unlock(&ctx->qqpipe_lock);
+ free(msg);
+ return UB_PIPE;
+ }
lock_basic_unlock(&ctx->qqpipe_lock);
free(msg);
return UB_NOERROR;