Sun Oct  5 11:42:09 2003  dean gaudet <dean@arctic.org>

  * modify the NOTIFY delay algorithm in ns_notify.c -- formerly
    the upper bound depended on the number of zones configured.
    now the upper bound depends on the number of NOTIFYs which
    need to be issued.  this makes much more sense when you're
    changing only one or two zones in a reload.

--- bind-8.3.3.orig/src/bin/named/ns_notify.c
+++ bind-8.3.3/src/bin/named/ns_notify.c
@@ -77,6 +77,10 @@
 
 /* Local. */
 
+/* number_of_notifies is the total number of entries in both
+ * the pending_notifies and loading_notifies lists
+ */
+static unsigned number_of_notifies;
 static LIST(struct pnotify) pending_notifies;
 static LIST(struct pnotify) loading_notifies;
 
@@ -134,12 +138,15 @@
 
 	if (loading != 0) {
 		APPEND(loading_notifies, ni, link);
+		++number_of_notifies;
 		return;
 	}
 
-	/* Delay notification for from five seconds up to fifteen minutes. */
-	max_delay = MIN(nzones, 895);
-	max_delay = MAX(max_delay, 25);
+	/* Delay notification for from five seconds up to fifteen minutes
+	 * depending on the total number of notifies we need to issue.
+	 */
+	max_delay = MIN(number_of_notifies, 895);
+	max_delay = MAX(max_delay, 10);
 	delay = 5 + (rand() % max_delay);
 	if (evSetTimer(ev, notify_timer, ni,
 		       evAddTime(evNowTime(), evConsTime(delay, 0)),
@@ -153,6 +160,7 @@
 
 	zp->z_flags |= Z_NOTIFY;
 	APPEND(pending_notifies, ni, link);
+	++number_of_notifies;
 	ns_debug(ns_log_notify, 3,
 		 "ns_notify(%s, %s, %s): ni %p, zp %p, delay %d",
 		 (dname && *dname) ? dname : ".",
@@ -167,6 +175,7 @@
 	INSIST(loading == 0);
 	while ((ni = HEAD(loading_notifies)) != NULL) {
 		UNLINK(loading_notifies, ni, link);
+		--number_of_notifies;
 		ns_notify(ni->name, ni->class, ni->type);
 		ni->name = freestr(ni->name);
 		memput(ni, sizeof *ni);
@@ -184,6 +193,7 @@
 
 		INSIST(LINKED(ni, link));
 		UNLINK(pending_notifies, ni, link);
+		--number_of_notifies;
 		free_notify(ni);
 	}
 }
@@ -203,6 +213,7 @@
 
 	if (ni != NULL) {
 		UNLINK(pending_notifies, ni, link);
+		--number_of_notifies;
 		free_notify(ni);
 	}
 }
@@ -455,6 +466,7 @@
 	evInitID(&ni->timer);
 	INSIST(LINKED(ni, link));
 	UNLINK(pending_notifies, ni, link);
+	--number_of_notifies;
 	sysnotify(ni->name, ni->class, ni->type);
 	free_notify(ni);
 }
