Commit Diff
Diff:
4806ae133c793ff0fe41f55b06ce4b49cfad0cb5
7f106daf657b927be40f8c4e4087232b9734620c
Commit:
7f106daf657b927be40f8c4e4087232b9734620c
Tree:
45685b7620189474a97b0fe5cd85c128c3d9ea13
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Mon Nov 18 15:49:45 2019 UTC
Message:
when delphinusdnsd replicant starts up most zones are probably updated and current, so we don't need to check refresh immediately. Here is an algorithm that spreads out the first time a refresh is done so that they are all offset by the time they check refresh on a continued periodic basis. fix some missing free()'s
blob - a199c65c167b61397b47d411489b091b0396bbcd
blob + ed41307d89bf1cc94c786373c3db14437f9f979c
--- raxfr.c
+++ raxfr.c
@@ -26,7 +26,7 @@
*
*/
/*
- * $Id: raxfr.c,v 1.32 2019/11/11 09:15:40 pjp Exp $
+ * $Id: raxfr.c,v 1.33 2019/11/18 15:49:45 pjp Exp $
*/
#include <sys/types.h>
@@ -1267,7 +1267,10 @@ replicantloop(ddDB *db, struct imsgbuf *ibuf, struct i
char *dn = NULL;
char *humanconv = NULL;
+ int period, tot_refresh = 0, zonecount = 1;
+ int add_period = 0;
+
#if __OpenBSD__
if (pledge("stdio wpath rpath cpath inet", NULL) < 0) {
perror("pledge");
@@ -1293,12 +1296,14 @@ replicantloop(ddDB *db, struct imsgbuf *ibuf, struct i
if (rrset == NULL) {
dolog(LOG_INFO, "%s has no SOA, removing zone from replicant engine\n", lrz->zonename);
SLIST_REMOVE(&rzones, lrz, rzone, rzone_entry);
+ free(rbt);
continue;
}
rrp = TAILQ_FIRST(&rrset->rr_head);
if (rrp == NULL) {
dolog(LOG_INFO, "SOA record corrupted for zone %s, removing zone from replicant engine\n", lrz->zonename);
SLIST_REMOVE(&rzones, lrz, rzone, rzone_entry);
+ free(rbt);
continue;
}
@@ -1311,9 +1316,24 @@ replicantloop(ddDB *db, struct imsgbuf *ibuf, struct i
lrz->soa.serial, lrz->soa.refresh, lrz->soa.retry,
lrz->soa.expire);
- now = time(NULL);
- schedule_refresh(lrz->zonename, now + lrz->soa.refresh);
+ zonecount++;
+ tot_refresh += lrz->soa.refresh;
+
free(rbt);
+ }
+
+ period = (tot_refresh / zonecount) / zonecount;
+ add_period = period;
+
+ SLIST_FOREACH_SAFE(lrz, &rzones, rzone_entry, lrz0) {
+ if (lrz->zonename == NULL)
+ continue;
+
+ now = time(NULL);
+ now += period;
+ dolog(LOG_INFO, "refreshing %s at %s\n", lrz->zonename, ctime(&now));
+ schedule_refresh(lrz->zonename, now);
+ period += add_period;
}
for (;;) {
repomaster@centroid.eu