mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 23:55:27 +00:00
simplified isc_random_jitter() and eliminated floating
point from the code using it in zone.c
This commit is contained in:
6
CHANGES
6
CHANGES
@@ -184,9 +184,9 @@
|
|||||||
to break up the key data in a "trusted-keys"
|
to break up the key data in a "trusted-keys"
|
||||||
statement into multiple lines. [RT #284]
|
statement into multiple lines. [RT #284]
|
||||||
|
|
||||||
432. [func] Added refresh/retry jitter. This is currently
|
432. [func] Added refresh/retry jitter. The actual refresh/
|
||||||
hard-coded to be no more than 20% of the SOA
|
retry time is now a random value between 75% and
|
||||||
provided time or 10 minutes, whichever is less.
|
100% of the configured value.
|
||||||
|
|
||||||
431. [func] Log at ISC_LOG_INFO when a zone is successfully
|
431. [func] Log at ISC_LOG_INFO when a zone is successfully
|
||||||
loaded.
|
loaded.
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: zone.c,v 1.218 2000/09/26 16:32:39 gson Exp $ */
|
/* $Id: zone.c,v 1.219 2000/09/26 17:23:19 gson Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -90,9 +90,6 @@
|
|||||||
#define DNS_MAX_EXPIRE 14515200 /* 24 weeks */
|
#define DNS_MAX_EXPIRE 14515200 /* 24 weeks */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define REFRESH_JITTER 600 /* seconds */
|
|
||||||
#define RETRY_JITTER 600
|
|
||||||
|
|
||||||
typedef struct dns_notify dns_notify_t;
|
typedef struct dns_notify dns_notify_t;
|
||||||
typedef struct dns_stub dns_stub_t;
|
typedef struct dns_stub dns_stub_t;
|
||||||
typedef struct dns_load dns_load_t;
|
typedef struct dns_load dns_load_t;
|
||||||
@@ -1784,9 +1781,8 @@ dns_zone_refresh(dns_zone_t *zone) {
|
|||||||
* Setting this to the retry time will do that. XXXMLG
|
* Setting this to the retry time will do that. XXXMLG
|
||||||
* If we are successful it will be reset using zone->refresh.
|
* If we are successful it will be reset using zone->refresh.
|
||||||
*/
|
*/
|
||||||
zone->refreshtime = now + isc_random_jitter(zone->retry,
|
zone->refreshtime = now +
|
||||||
zone->retry * .80,
|
isc_random_jitter(zone->retry, zone->retry / 4);
|
||||||
RETRY_JITTER);
|
|
||||||
zone_log(zone, "dns_zone_refresh", ISC_LOG_DEBUG(20),
|
zone_log(zone, "dns_zone_refresh", ISC_LOG_DEBUG(20),
|
||||||
"refresh time (%u/%u), now %u",
|
"refresh time (%u/%u), now %u",
|
||||||
zone->refreshtime, zone->refresh, now);
|
zone->refreshtime, zone->refresh, now);
|
||||||
@@ -2677,8 +2673,7 @@ stub_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
LOCK(&zone->lock);
|
LOCK(&zone->lock);
|
||||||
zone->flags &= ~DNS_ZONEFLG_REFRESH;
|
zone->flags &= ~DNS_ZONEFLG_REFRESH;
|
||||||
zone->refreshtime = now +
|
zone->refreshtime = now +
|
||||||
isc_random_jitter(zone->refresh, zone->refresh * .80,
|
isc_random_jitter(zone->refresh, zone->refresh / 4);
|
||||||
REFRESH_JITTER);
|
|
||||||
zone->expiretime = now + zone->expire;
|
zone->expiretime = now + zone->expire;
|
||||||
zone_log(zone, me, ISC_LOG_DEBUG(20),
|
zone_log(zone, me, ISC_LOG_DEBUG(20),
|
||||||
"refresh time (%u/%u), now %u",
|
"refresh time (%u/%u), now %u",
|
||||||
@@ -2925,8 +2920,7 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
dns_result_totext(result));
|
dns_result_totext(result));
|
||||||
}
|
}
|
||||||
zone->refreshtime = now +
|
zone->refreshtime = now +
|
||||||
isc_random_jitter(zone->refresh, zone->refresh * .80,
|
isc_random_jitter(zone->refresh, zone->refresh / 4);
|
||||||
REFRESH_JITTER);
|
|
||||||
zone->expiretime = now + zone->expire;
|
zone->expiretime = now + zone->expire;
|
||||||
zone_log(zone, me, ISC_LOG_DEBUG(20),
|
zone_log(zone, me, ISC_LOG_DEBUG(20),
|
||||||
"refresh time (%u/%u), now %u",
|
"refresh time (%u/%u), now %u",
|
||||||
@@ -4275,8 +4269,7 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) {
|
|||||||
} else {
|
} else {
|
||||||
zone->refreshtime = now +
|
zone->refreshtime = now +
|
||||||
isc_random_jitter(zone->refresh,
|
isc_random_jitter(zone->refresh,
|
||||||
zone->refresh * .80,
|
zone->refresh / 4);
|
||||||
REFRESH_JITTER);
|
|
||||||
zone_log(zone, me, ISC_LOG_DEBUG(20),
|
zone_log(zone, me, ISC_LOG_DEBUG(20),
|
||||||
"refresh time (%u/%u), now %u",
|
"refresh time (%u/%u), now %u",
|
||||||
zone->refreshtime, zone->refresh, now);
|
zone->refreshtime, zone->refresh, now);
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: random.h,v 1.9 2000/09/06 16:25:35 gson Exp $ */
|
/* $Id: random.h,v 1.10 2000/09/26 17:23:16 gson Exp $ */
|
||||||
|
|
||||||
#ifndef ISC_RANDOM_H
|
#ifndef ISC_RANDOM_H
|
||||||
#define ISC_RANDOM_H 1
|
#define ISC_RANDOM_H 1
|
||||||
@@ -49,11 +49,10 @@ isc_random_get(isc_uint32_t *val);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
isc_uint32_t
|
isc_uint32_t
|
||||||
isc_random_jitter(isc_uint32_t max, isc_uint32_t min, isc_uint32_t jitter);
|
isc_random_jitter(isc_uint32_t max, isc_uint32_t jitter);
|
||||||
/*
|
/*
|
||||||
* Return a value between (max - jitter) and (max).
|
* Get a random value between (max - jitter) and (max).
|
||||||
*
|
* This is useful for jittering timer values.
|
||||||
* If (max - min) < jitter, the maximum jitter becomes (max - min) instead.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ISC_LANG_ENDDECLS
|
ISC_LANG_ENDDECLS
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: random.c,v 1.12 2000/09/08 00:06:39 explorer Exp $ */
|
/* $Id: random.c,v 1.13 2000/09/26 17:23:17 gson Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -60,22 +60,10 @@ isc_random_get(isc_uint32_t *val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
isc_uint32_t
|
isc_uint32_t
|
||||||
isc_random_jitter(isc_uint32_t max, isc_uint32_t min, isc_uint32_t jitter) {
|
isc_random_jitter(isc_uint32_t max, isc_uint32_t jitter) {
|
||||||
isc_uint32_t val;
|
REQUIRE(jitter < max);
|
||||||
|
|
||||||
REQUIRE(jitter > 0);
|
|
||||||
|
|
||||||
if (min >= max)
|
|
||||||
return (min);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Don't allow jitter to be more than max - min.
|
|
||||||
*/
|
|
||||||
if (jitter > max - min)
|
|
||||||
jitter = max - min;
|
|
||||||
if (jitter == 0)
|
if (jitter == 0)
|
||||||
return (min);
|
return (max);
|
||||||
|
else
|
||||||
val = rand() % jitter;
|
return (max - rand() % jitter);
|
||||||
return (max - val);
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user