]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
pickup worker events, and free them.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 31 Jan 2018 12:33:19 +0000 (12:33 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 31 Jan 2018 12:33:19 +0000 (12:33 +0000)
exponential backoff for continuously failing zones.

git-svn-id: file:///svn/unbound/trunk@4479 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/daemon.c
daemon/worker.c
services/authzone.c
services/authzone.h

index 6f82ca60a616ac0149cfa23eda536e9152571e8c..c56581b8bc7cd5dc8274d6328a82fb4905aea738 100644 (file)
@@ -695,6 +695,8 @@ daemon_cleanup(struct daemon* daemon)
        daemon->respip_set = NULL;
        views_delete(daemon->views);
        daemon->views = NULL;
+       auth_zones_delete(daemon->env->auth_zones);
+       daemon->env->auth_zones = NULL;
        /* key cache is cleared by module desetup during next daemon_fork() */
        daemon_remote_clear(daemon->rc);
        for(i=0; i<daemon->num; i++)
@@ -728,7 +730,6 @@ daemon_delete(struct daemon* daemon)
                rrset_cache_delete(daemon->env->rrset_cache);
                infra_delete(daemon->env->infra_cache);
                edns_known_options_delete(daemon->env);
-               auth_zones_delete(daemon->env->auth_zones);
        }
        ub_randfree(daemon->rand);
        alloc_clear(&daemon->superalloc);
index a382bbb890b2c9625351598d639cadbd07ca2d8e..7caa11318b6b8e661d62e980b8ef2c9c939bfc9b 100644 (file)
@@ -1738,6 +1738,14 @@ worker_init(struct worker* worker, struct config_file *cfg,
                        comm_timer_set(worker->env.probe_timer, &tv);
                }
        }
+       /* zone transfer tasks, setup once per process, if any */
+       if(worker->env.auth_zones
+#ifndef THREADS_DISABLED
+               && worker->thread_num == 0
+#endif
+               ) {
+               auth_xfer_pickup_initial(worker->env.auth_zones, &worker->env);
+       }
        if(!worker->env.mesh || !worker->env.scratch_buffer) {
                worker_delete(worker);
                return 0;
index 406ed819040f4f9ee00b13686f2861b1570c50c1..d3ec1e8d03c5b3c1bc0d920c1188c44b6eed21eb 100644 (file)
@@ -78,6 +78,8 @@
 #define AUTH_PROBE_TIMEOUT_STOP 1000 /* msec */
 /* auth transfer timeout for TCP connections, in msec */
 #define AUTH_TRANSFER_TIMEOUT 10000 /* msec */
+/* auth transfer max backoff for failed tranfers and probes */
+#define AUTH_TRANSFER_MAX_BACKOFF 86400 /* sec */
 
 /** pick up nextprobe task to start waiting to perform transfer actions */
 static void xfr_set_timeout(struct auth_xfer* xfr, struct module_env* env,
@@ -5086,6 +5088,21 @@ xfr_set_timeout(struct auth_xfer* xfr, struct module_env* env,
                if(xfr->expiry < wait)
                        xfr->task_nextprobe->next_probe += xfr->expiry;
                else    xfr->task_nextprobe->next_probe += wait;
+               if(!failure) xfr->task_nextprobe->backoff = 0;
+       } else {
+               if(!failure) {
+                       xfr->task_nextprobe->backoff = 0;
+               } else {
+                       if(xfr->task_nextprobe->backoff == 0)
+                               xfr->task_nextprobe->backoff = 3;
+                       else    xfr->task_nextprobe->backoff *= 2;
+                       if(xfr->task_nextprobe->backoff >
+                               AUTH_TRANSFER_MAX_BACKOFF)
+                               xfr->task_nextprobe->backoff =
+                                       AUTH_TRANSFER_MAX_BACKOFF;
+               }
+               xfr->task_nextprobe->next_probe +=
+                       xfr->task_nextprobe->backoff;
        }
 
        if(!xfr->task_nextprobe->timer) {
index 7db4f4a568585049e83bbe0957d78eb28f4abe3f..93989cd2d7f52bbaa5846658459140a399b44c80 100644 (file)
@@ -259,6 +259,8 @@ struct auth_nextprobe {
        /* module env for this task */
        struct module_env* env;
 
+       /** increasing backoff for failures */
+       time_t backoff;
        /** Timeout for next probe (for SOA) */
        time_t next_probe;
        /** timeout callback for next_probe or expiry(if that is sooner).
@@ -431,6 +433,13 @@ struct auth_zones* auth_zones_create(void);
 int auth_zones_apply_cfg(struct auth_zones* az, struct config_file* cfg,
        int setup);
 
+/** initial pick up of worker timeouts, ties events to worker event loop
+ * @param az: auth zones structure
+ * @param env: worker env, of first worker that receives the events (if any)
+ *     in its eventloop.
+ */
+void auth_xfer_pickup_initial(struct auth_zones* az, struct module_env* env);
+
 /**
  * Delete auth zones structure
  */