]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
protect config access. fix test.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 28 Jan 2008 14:45:20 +0000 (14:45 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 28 Jan 2008 14:45:20 +0000 (14:45 +0000)
git-svn-id: file:///svn/unbound/trunk@908 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
libunbound/worker.c
testdata/05-asynclook.tpkg

index 69558ddf189fb1e98c6acd3f10b70bd0a23e862a..4ab938aeb09881acdde0157c1fec8171fbe7d54c 100644 (file)
@@ -9,6 +9,7 @@
        - random generator cleanup - RND_STATE_SIZE removed, and instead
          a super-rnd can be passed at init to chain init random states.
        - test also does lock checks if available.
+       - protect config access in libworker_setup().
 
 25 January 2008: Wouter
        - added tpkg for asynclook and library use. 
index 009e08b8f5d7369ae5c716f46badc12081afdb83..6b55b1d58623d1271850de73753813b640a7ad28 100644 (file)
@@ -108,8 +108,14 @@ libworker_setup(struct ub_val_ctx* ctx, int is_bg)
        }
        w->thread_num = w->env->alloc->thread_num;
        alloc_set_id_cleanup(w->env->alloc, &libworker_alloc_cleanup, w);
+       if(!w->is_bg || w->is_bg_thread) {
+               lock_basic_lock(&ctx->cfglock);
+       }
        w->env->scratch = regional_create_custom(cfg->msg_buffer_size);
        w->env->scratch_buffer = ldns_buffer_new(cfg->msg_buffer_size);
+       if(!w->is_bg || w->is_bg_thread) {
+               lock_basic_unlock(&ctx->cfglock);
+       }
        if(!w->env->scratch || !w->env->scratch_buffer) {
                libworker_delete(w);
                return NULL;
@@ -139,11 +145,17 @@ libworker_setup(struct ub_val_ctx* ctx, int is_bg)
                libworker_delete(w);
                return NULL;
        }
+       if(!w->is_bg || w->is_bg_thread) {
+               lock_basic_lock(&ctx->cfglock);
+       }
        w->back = outside_network_create(w->base, cfg->msg_buffer_size,
                (size_t)cfg->outgoing_num_ports, cfg->out_ifs,
                cfg->num_out_ifs, cfg->do_ip4, cfg->do_ip6, -1, 
                cfg->do_tcp?cfg->outgoing_num_tcp:0,
                w->env->infra_cache, w->env->rnd);
+       if(!w->is_bg || w->is_bg_thread) {
+               lock_basic_unlock(&ctx->cfglock);
+       }
        if(!w->back) {
                libworker_delete(w);
                return NULL;
index df7e08888a6ccfc92463cc5a2e1e0bfee756daf1..1fd0e332f66be0ff6d493a4c4d286e831e5a07e1 100644 (file)
Binary files a/testdata/05-asynclook.tpkg and b/testdata/05-asynclook.tpkg differ