From 0679bf6502887822b0afdb2dfc958ccdd7aef978 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Fri, 2 Oct 2009 08:08:44 +0000 Subject: [PATCH] Fix autotrust-5011 file used from libunbound (no probing by itself because it may not have the processor whenever it likes). git-svn-id: file:///svn/unbound/trunk@1857 be551aaa-1e26-0410-a405-d3ace91eadb9 --- daemon/worker.c | 38 +++++++++++++++++++------------------- daemon/worker.h | 2 -- doc/Changelog | 4 ++++ libunbound/libworker.c | 1 + util/module.h | 2 ++ validator/autotrust.c | 6 ++---- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/daemon/worker.c b/daemon/worker.c index 97cf40d0a..e8fe788ef 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -951,7 +951,7 @@ void worker_probe_timer_cb(void* arg) tv.tv_usec = 0; #endif if(tv.tv_sec != 0) - comm_timer_set(worker->probe_timer, &tv); + comm_timer_set(worker->env.probe_timer, &tv); } struct worker* @@ -1068,23 +1068,6 @@ worker_init(struct worker* worker, struct config_file *cfg, if(!worker->stat_timer) { log_err("could not create statistics timer"); } - /* one probe timer per process -- if we have 5011 anchors */ - if(autr_get_num_anchors(worker->daemon->env->anchors) > 0 -#ifndef THREADS_DISABLED - && worker->thread_num == 0 -#endif - ) { - struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = 0; - worker->probe_timer = comm_timer_create(worker->base, - worker_probe_timer_cb, worker); - if(!worker->probe_timer) { - log_err("could not create 5011-probe timer"); - } - /* let timer fire, then it can reset itself */ - comm_timer_set(worker->probe_timer, &tv); - } /* we use the msg_buffer_size as a good estimate for what the * user wants for memory usage sizes */ @@ -1122,6 +1105,23 @@ worker_init(struct worker* worker, struct config_file *cfg, worker_delete(worker); return 0; } + /* one probe timer per process -- if we have 5011 anchors */ + if(autr_get_num_anchors(worker->env.anchors) > 0 +#ifndef THREADS_DISABLED + && worker->thread_num == 0 +#endif + ) { + struct timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 0; + worker->env.probe_timer = comm_timer_create(worker->base, + worker_probe_timer_cb, worker); + if(!worker->env.probe_timer) { + log_err("could not create 5011-probe timer"); + } + /* let timer fire, then it can reset itself */ + comm_timer_set(worker->env.probe_timer, &tv); + } if(!worker->env.mesh || !worker->env.scratch_buffer) { worker_delete(worker); return 0; @@ -1161,7 +1161,7 @@ worker_delete(struct worker* worker) comm_signal_delete(worker->comsig); tube_delete(worker->cmd); comm_timer_delete(worker->stat_timer); - comm_timer_delete(worker->probe_timer); + comm_timer_delete(worker->env.probe_timer); free(worker->ports); if(worker->thread_num == 0) { log_set_time(NULL); diff --git a/daemon/worker.h b/daemon/worker.h index 993fa5e2b..2116d54d8 100644 --- a/daemon/worker.h +++ b/daemon/worker.h @@ -101,8 +101,6 @@ struct worker { struct comm_point* cmd_com; /** timer for statistics */ struct comm_timer* stat_timer; - /** timer for autotrust probes */ - struct comm_timer* probe_timer; /** number of requests that can be handled by this worker */ size_t request_size; diff --git a/doc/Changelog b/doc/Changelog index 108abdf5d..dfa5e0fa8 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,7 @@ +2 October 2009: Wouter + - improve 5011 modularization. + - fix unbound-host so -d can be given before -C. + 28 September 2009: Wouter - autotrust-anchor-file can read multiline input and $ORIGIN. - prevent integer overflow in holddown calculation. review fixes. diff --git a/libunbound/libworker.c b/libunbound/libworker.c index dcc093371..a35359c39 100644 --- a/libunbound/libworker.c +++ b/libunbound/libworker.c @@ -130,6 +130,7 @@ libworker_setup(struct ub_ctx* ctx, int is_bg) return NULL; } w->env->worker = (struct worker*)w; + w->env->probe_timer = NULL; seed = (unsigned int)time(NULL) ^ (unsigned int)getpid() ^ (((unsigned int)w->thread_num)<<17); seed ^= (unsigned int)w->env->alloc->next_id; diff --git a/util/module.h b/util/module.h index 8c430affa..3f228314d 100644 --- a/util/module.h +++ b/util/module.h @@ -212,6 +212,8 @@ struct module_env { /** negative cache, configured by the validator. if not NULL, * contains NSEC record lookup trees. */ struct val_neg_cache* neg_cache; + /** the 5011-probe timer (if any) */ + struct comm_timer* probe_timer; /** Mapping of forwarding zones to targets. * iterator forwarder information. per-thread, created by worker */ struct iter_forwards* fwds; diff --git a/validator/autotrust.c b/validator/autotrust.c index 7ac2c8635..5568300f0 100644 --- a/validator/autotrust.c +++ b/validator/autotrust.c @@ -57,7 +57,6 @@ #include "services/mesh.h" #include "services/cache/rrset.h" #include "validator/val_kcache.h" -#include "daemon/worker.h" /** number of times a key must be seen before it can become valid */ #define MIN_PENDINGCOUNT 2 @@ -1625,19 +1624,18 @@ wait_probe_time(struct val_anchors* anchors) static void reset_worker_timer(struct module_env* env) { - struct worker* worker = env->worker; struct timeval tv; #ifndef S_SPLINT_S uint32_t next = (uint32_t)wait_probe_time(env->anchors); /* in case this is libunbound, no timer */ - if(!worker || !worker->probe_timer) + if(!env->probe_timer) return; if(next > *env->now) tv.tv_sec = (time_t)(next - *env->now); else tv.tv_sec = 0; #endif tv.tv_usec = 0; - comm_timer_set(worker->probe_timer, &tv); + comm_timer_set(env->probe_timer, &tv); verbose(VERB_ALGO, "scheduled next probe in %d sec", (int)tv.tv_sec); } -- 2.47.3