From: Wouter Wijngaards Date: Fri, 25 Jan 2008 16:17:36 +0000 (+0000) Subject: smaller fixes. X-Git-Tag: release-0.9~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6c543362d7b043e1b6efdcc3753629d285713e5;p=thirdparty%2Funbound.git smaller fixes. git-svn-id: file:///svn/unbound/trunk@904 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/libunbound/unbound.c b/libunbound/unbound.c index 6a650592d..81c8e46a2 100644 --- a/libunbound/unbound.c +++ b/libunbound/unbound.c @@ -162,8 +162,21 @@ ub_val_ctx_delete(struct ub_val_ctx* ctx) 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; @@ -561,7 +574,9 @@ ub_val_resolve_async(struct ub_val_ctx* ctx, char* name, int rrtype, 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); @@ -583,7 +598,11 @@ ub_val_resolve_async(struct ub_val_ctx* ctx, char* name, int rrtype, 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; @@ -620,7 +639,11 @@ ub_val_cancel(struct ub_val_ctx* ctx, int async_id) /* 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; diff --git a/libunbound/worker.c b/libunbound/worker.c index feb1985b7..78bb1c496 100644 --- a/libunbound/worker.c +++ b/libunbound/worker.c @@ -280,6 +280,7 @@ libworker_dobg(void* arg) ctx->rrpipe[0] = -1; } #endif + log_info("dobg start"); if(!w) { log_err("libunbound bg worker init failed, nomem"); return NULL; diff --git a/testcode/asynclook.c b/testcode/asynclook.c index ad8de9546..37ad2cb7c 100644 --- a/testcode/asynclook.c +++ b/testcode/asynclook.c @@ -246,7 +246,6 @@ ext_test(struct ub_val_ctx* ctx, int argc, char** argv) } printf("extended test end\n"); ub_val_ctx_delete(ctx); - sleep(1); /* give bg thread time to exit */ checklock_stop(); return 0; }