aboutsummaryrefslogtreecommitdiff
path: root/libunbound
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2024-05-10 20:48:53 +0000
committerCy Schubert <cy@FreeBSD.org>2024-05-10 20:48:53 +0000
commitc2a80056864d6eda0398fd127dc0ae515b39752b (patch)
tree92e6196ae61df0fa7e4db654f78dfd837cc41826 /libunbound
parent5a33598e88ad8fbc0affa74dee0a2d8cc4010fbc (diff)
Diffstat (limited to 'libunbound')
-rw-r--r--libunbound/context.c8
-rw-r--r--libunbound/libunbound.c5
-rw-r--r--libunbound/libworker.c21
3 files changed, 16 insertions, 18 deletions
diff --git a/libunbound/context.c b/libunbound/context.c
index f7c0a2cd5fae..a319f59cdea8 100644
--- a/libunbound/context.c
+++ b/libunbound/context.c
@@ -53,6 +53,8 @@
#include "util/storage/slabhash.h"
#include "util/edns.h"
#include "sldns/sbuffer.h"
+#include "iterator/iter_fwd.h"
+#include "iterator/iter_hints.h"
int
context_finalize(struct ub_ctx* ctx)
@@ -85,6 +87,12 @@ context_finalize(struct ub_ctx* ctx)
if(!auth_zones_apply_cfg(ctx->env->auth_zones, cfg, 1, &is_rpz,
ctx->env, &ctx->mods))
return UB_INITFAIL;
+ if(!(ctx->env->fwds = forwards_create()) ||
+ !forwards_apply_cfg(ctx->env->fwds, cfg))
+ return UB_INITFAIL;
+ if(!(ctx->env->hints = hints_create()) ||
+ !hints_apply_cfg(ctx->env->hints, cfg))
+ return UB_INITFAIL;
if(!edns_strings_apply_cfg(ctx->env->edns_strings, cfg))
return UB_INITFAIL;
if(!slabhash_is_size(ctx->env->msg_cache, cfg->msg_cache_size,
diff --git a/libunbound/libunbound.c b/libunbound/libunbound.c
index 80a82bb47ddf..17057ec6c014 100644
--- a/libunbound/libunbound.c
+++ b/libunbound/libunbound.c
@@ -66,6 +66,8 @@
#include "services/authzone.h"
#include "services/listen_dnsport.h"
#include "sldns/sbuffer.h"
+#include "iterator/iter_fwd.h"
+#include "iterator/iter_hints.h"
#ifdef HAVE_PTHREAD
#include <signal.h>
#endif
@@ -171,6 +173,7 @@ static struct ub_ctx* ub_ctx_create_nopipe(void)
ctx->env->worker = NULL;
ctx->env->need_to_validate = 0;
modstack_init(&ctx->mods);
+ ctx->env->modstack = &ctx->mods;
rbtree_init(&ctx->queries, &context_query_cmp);
return ctx;
}
@@ -379,6 +382,8 @@ ub_ctx_delete(struct ub_ctx* ctx)
config_delete(ctx->env->cfg);
edns_known_options_delete(ctx->env);
edns_strings_delete(ctx->env->edns_strings);
+ forwards_delete(ctx->env->fwds);
+ hints_delete(ctx->env->hints);
auth_zones_delete(ctx->env->auth_zones);
free(ctx->env);
}
diff --git a/libunbound/libworker.c b/libunbound/libworker.c
index 0e1c40393763..5c75f61d8dcb 100644
--- a/libunbound/libworker.c
+++ b/libunbound/libworker.c
@@ -70,8 +70,6 @@
#include "util/data/msgreply.h"
#include "util/data/msgencode.h"
#include "util/tube.h"
-#include "iterator/iter_fwd.h"
-#include "iterator/iter_hints.h"
#include "sldns/sbuffer.h"
#include "sldns/str2wire.h"
#ifdef USE_DNSTAP
@@ -100,8 +98,6 @@ libworker_delete_env(struct libworker* w)
!w->is_bg || w->is_bg_thread);
sldns_buffer_free(w->env->scratch_buffer);
regional_destroy(w->env->scratch);
- forwards_delete(w->env->fwds);
- hints_delete(w->env->hints);
ub_randfree(w->env->rnd);
free(w->env);
}
@@ -159,30 +155,19 @@ libworker_setup(struct ub_ctx* ctx, int is_bg, struct ub_event_base* eb)
}
w->env->scratch = regional_create_custom(cfg->msg_buffer_size);
w->env->scratch_buffer = sldns_buffer_new(cfg->msg_buffer_size);
- w->env->fwds = forwards_create();
- if(w->env->fwds && !forwards_apply_cfg(w->env->fwds, cfg)) {
- forwards_delete(w->env->fwds);
- w->env->fwds = NULL;
- }
- w->env->hints = hints_create();
- if(w->env->hints && !hints_apply_cfg(w->env->hints, cfg)) {
- hints_delete(w->env->hints);
- w->env->hints = NULL;
- }
#ifdef HAVE_SSL
w->sslctx = connect_sslctx_create(NULL, NULL,
cfg->tls_cert_bundle, cfg->tls_win_cert);
if(!w->sslctx) {
/* to make the setup fail after unlock */
- hints_delete(w->env->hints);
- w->env->hints = NULL;
+ sldns_buffer_free(w->env->scratch_buffer);
+ w->env->scratch_buffer = NULL;
}
#endif
if(!w->is_bg || w->is_bg_thread) {
lock_basic_unlock(&ctx->cfglock);
}
- if(!w->env->scratch || !w->env->scratch_buffer || !w->env->fwds ||
- !w->env->hints) {
+ if(!w->env->scratch || !w->env->scratch_buffer) {
libworker_delete(w);
return NULL;
}