From 80424bc16efce5b297047e8591483dbd847e854b Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Fri, 14 Oct 2011 07:15:41 +0000 Subject: [PATCH] - Fix for out-of-memory condition in libunbound (thanks Robert Fleischman). git-svn-id: file:///svn/unbound/trunk@2511 be551aaa-1e26-0410-a405-d3ace91eadb9 --- doc/Changelog | 4 ++++ libunbound/libworker.c | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index c90f6e34a..a7daa18b7 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,7 @@ +14 October 2011: Wouter + - Fix for out-of-memory condition in libunbound (thanks + Robert Fleischman). + 13 October 2011: Wouter - Fix --enable-allsymbols, it depended on link specifics of the target platform, or fptr_wlist assertion failures could occur. diff --git a/libunbound/libworker.c b/libunbound/libworker.c index 673d3430f..6aa19e203 100644 --- a/libunbound/libworker.c +++ b/libunbound/libworker.c @@ -261,7 +261,12 @@ libworker_dobg(void* arg) /* setup */ uint32_t m; struct libworker* w = (struct libworker*)arg; - struct ub_ctx* ctx = w->ctx; + struct ub_ctx* ctx; + if(!w) { + log_err("libunbound bg worker init failed, nomem"); + return NULL; + } + ctx = w->ctx; log_thread_set(&w->thread_num); #ifdef THREADS_DISABLED /* we are forked */ @@ -270,10 +275,6 @@ libworker_dobg(void* arg) tube_close_write(ctx->qq_pipe); tube_close_read(ctx->rr_pipe); #endif - if(!w) { - log_err("libunbound bg worker init failed, nomem"); - return NULL; - } if(!tube_setup_bg_listen(ctx->qq_pipe, w->base, libworker_handle_control_cmd, w)) { log_err("libunbound bg worker init failed, no bglisten"); @@ -310,11 +311,11 @@ int libworker_bg(struct ub_ctx* ctx) if(ctx->dothread) { lock_basic_unlock(&ctx->cfglock); w = libworker_setup(ctx, 1); + if(!w) return UB_NOMEM; w->is_bg_thread = 1; #ifdef ENABLE_LOCK_CHECKS w->thread_num = 1; /* for nicer DEBUG checklocks */ #endif - if(!w) return UB_NOMEM; ub_thread_create(&ctx->bg_tid, libworker_dobg, w); } else { lock_basic_unlock(&ctx->cfglock); -- 2.47.2