2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-02 15:45:25 +00:00

simplified isc_random_jitter() and eliminated floating

point from the code using it in zone.c
This commit is contained in:
Andreas Gustafsson
2000-09-26 17:23:19 +00:00
parent d8c339062c
commit 94361d5867
4 changed files with 19 additions and 39 deletions

View File

@@ -184,9 +184,9 @@
to break up the key data in a "trusted-keys"
statement into multiple lines. [RT #284]
432. [func] Added refresh/retry jitter. This is currently
hard-coded to be no more than 20% of the SOA
provided time or 10 minutes, whichever is less.
432. [func] Added refresh/retry jitter. The actual refresh/
retry time is now a random value between 75% and
100% of the configured value.
431. [func] Log at ISC_LOG_INFO when a zone is successfully
loaded.

View File

@@ -15,7 +15,7 @@
* 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>
@@ -90,9 +90,6 @@
#define DNS_MAX_EXPIRE 14515200 /* 24 weeks */
#endif
#define REFRESH_JITTER 600 /* seconds */
#define RETRY_JITTER 600
typedef struct dns_notify dns_notify_t;
typedef struct dns_stub dns_stub_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
* If we are successful it will be reset using zone->refresh.
*/
zone->refreshtime = now + isc_random_jitter(zone->retry,
zone->retry * .80,
RETRY_JITTER);
zone->refreshtime = now +
isc_random_jitter(zone->retry, zone->retry / 4);
zone_log(zone, "dns_zone_refresh", ISC_LOG_DEBUG(20),
"refresh time (%u/%u), now %u",
zone->refreshtime, zone->refresh, now);
@@ -2677,8 +2673,7 @@ stub_callback(isc_task_t *task, isc_event_t *event) {
LOCK(&zone->lock);
zone->flags &= ~DNS_ZONEFLG_REFRESH;
zone->refreshtime = now +
isc_random_jitter(zone->refresh, zone->refresh * .80,
REFRESH_JITTER);
isc_random_jitter(zone->refresh, zone->refresh / 4);
zone->expiretime = now + zone->expire;
zone_log(zone, me, ISC_LOG_DEBUG(20),
"refresh time (%u/%u), now %u",
@@ -2925,8 +2920,7 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
dns_result_totext(result));
}
zone->refreshtime = now +
isc_random_jitter(zone->refresh, zone->refresh * .80,
REFRESH_JITTER);
isc_random_jitter(zone->refresh, zone->refresh / 4);
zone->expiretime = now + zone->expire;
zone_log(zone, me, ISC_LOG_DEBUG(20),
"refresh time (%u/%u), now %u",
@@ -4275,8 +4269,7 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) {
} else {
zone->refreshtime = now +
isc_random_jitter(zone->refresh,
zone->refresh * .80,
REFRESH_JITTER);
zone->refresh / 4);
zone_log(zone, me, ISC_LOG_DEBUG(20),
"refresh time (%u/%u), now %u",
zone->refreshtime, zone->refresh, now);

View File

@@ -15,7 +15,7 @@
* 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
#define ISC_RANDOM_H 1
@@ -49,11 +49,10 @@ isc_random_get(isc_uint32_t *val);
*/
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).
*
* If (max - min) < jitter, the maximum jitter becomes (max - min) instead.
* Get a random value between (max - jitter) and (max).
* This is useful for jittering timer values.
*/
ISC_LANG_ENDDECLS

View File

@@ -15,7 +15,7 @@
* 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>
@@ -60,22 +60,10 @@ isc_random_get(isc_uint32_t *val)
}
isc_uint32_t
isc_random_jitter(isc_uint32_t max, isc_uint32_t min, isc_uint32_t jitter) {
isc_uint32_t val;
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;
isc_random_jitter(isc_uint32_t max, isc_uint32_t jitter) {
REQUIRE(jitter < max);
if (jitter == 0)
return (min);
val = rand() % jitter;
return (max - val);
return (max);
else
return (max - rand() % jitter);
}