smaller fixes.

git-svn-id: file:///svn/unbound/trunk@904 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2008-01-25 16:17:36 +00:00
parent 32396dc677
commit a6c543362d
3 changed files with 28 additions and 5 deletions

View file

@ -162,8 +162,21 @@ ub_val_ctx_delete(struct ub_val_ctx* ctx)
free(msg); free(msg);
} }
lock_basic_unlock(&ctx->rrpipe_lock); 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); modstack_desetup(&ctx->mods, ctx->env);
a = ctx->alloc_list; a = ctx->alloc_list;
@ -561,7 +574,9 @@ ub_val_resolve_async(struct ub_val_ctx* ctx, char* name, int rrtype,
lock_basic_unlock(&ctx->cfglock); lock_basic_unlock(&ctx->cfglock);
return r; 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 */ /* 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, mydata);
@ -583,7 +598,11 @@ ub_val_resolve_async(struct ub_val_ctx* ctx, char* name, int rrtype,
lock_basic_unlock(&ctx->cfglock); lock_basic_unlock(&ctx->cfglock);
lock_basic_lock(&ctx->qqpipe_lock); 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); lock_basic_unlock(&ctx->qqpipe_lock);
free(msg); free(msg);
return UB_NOERROR; return UB_NOERROR;
@ -620,7 +639,11 @@ ub_val_cancel(struct ub_val_ctx* ctx, int async_id)
/* send cancel to background worker */ /* send cancel to background worker */
lock_basic_lock(&ctx->qqpipe_lock); 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); lock_basic_unlock(&ctx->qqpipe_lock);
free(msg); free(msg);
return UB_NOERROR; return UB_NOERROR;

View file

@ -280,6 +280,7 @@ libworker_dobg(void* arg)
ctx->rrpipe[0] = -1; ctx->rrpipe[0] = -1;
} }
#endif #endif
log_info("dobg start");
if(!w) { if(!w) {
log_err("libunbound bg worker init failed, nomem"); log_err("libunbound bg worker init failed, nomem");
return NULL; return NULL;

View file

@ -246,7 +246,6 @@ ext_test(struct ub_val_ctx* ctx, int argc, char** argv)
} }
printf("extended test end\n"); printf("extended test end\n");
ub_val_ctx_delete(ctx); ub_val_ctx_delete(ctx);
sleep(1); /* give bg thread time to exit */
checklock_stop(); checklock_stop();
return 0; return 0;
} }