Blame SOURCES/dhcp-isc_heap_delete.patch

072f0f
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
072f0f
index 52ba677..deea2a7 100644
072f0f
--- a/includes/dhcpd.h
072f0f
+++ b/includes/dhcpd.h
072f0f
@@ -1521,8 +1521,9 @@ struct iasubopt {
072f0f
  */
072f0f
 #define EXPIRED_IPV6_CLEANUP_TIME (60*60)
072f0f
 
072f0f
-	int heap_index;				/* index into heap, or -1
072f0f
-						   (internal use only) */
072f0f
+	/* index into heaps, or -1 (internal use only) */
072f0f
+	int active_index;
072f0f
+	int inactive_index;
072f0f
 
072f0f
 	/*
072f0f
 	 * A pointer to the state of the ddns update for this lease.
072f0f
diff --git a/server/mdb6.c b/server/mdb6.c
072f0f
index 0e76264..711ab3d 100644
072f0f
--- a/server/mdb6.c
072f0f
+++ b/server/mdb6.c
072f0f
@@ -130,7 +130,8 @@ iasubopt_allocate(struct iasubopt **iasubopt, const char *file, int line) {
072f0f
 
072f0f
 	tmp->refcnt = 1;
072f0f
 	tmp->state = FTS_FREE;
072f0f
-	tmp->heap_index = -1;
072f0f
+	tmp->active_index = -1;
072f0f
+	tmp->inactive_index = -1;
072f0f
 	tmp->plen = 255;
072f0f
 
072f0f
 	*iasubopt = tmp;
072f0f
@@ -504,10 +505,14 @@ lease_older(void *a, void *b) {
072f0f
  * Callback when an address's position in the heap changes.
072f0f
  */
072f0f
 static void
072f0f
-lease_index_changed(void *iasubopt, unsigned int new_heap_index) {
072f0f
-	((struct iasubopt *)iasubopt)-> heap_index = new_heap_index;
072f0f
+active_changed(void *iasubopt, unsigned int new_heap_index) {
072f0f
+	((struct iasubopt *)iasubopt)-> active_index = new_heap_index;
072f0f
 }
072f0f
 
072f0f
+static void
072f0f
+inactive_changed(void *iasubopt, unsigned int new_heap_index) {
072f0f
+	((struct iasubopt *)iasubopt)-> inactive_index = new_heap_index;
072f0f
+}
072f0f
 
072f0f
 /*
072f0f
  * Create a new IPv6 lease pool structure.
072f0f
@@ -544,13 +549,13 @@ ipv6_pool_allocate(struct ipv6_pool **pool, u_int16_t type,
072f0f
 		dfree(tmp, file, line);
072f0f
 		return ISC_R_NOMEMORY;
072f0f
 	}
072f0f
-	if (isc_heap_create(dhcp_gbl_ctx.mctx, lease_older, lease_index_changed,
072f0f
+	if (isc_heap_create(dhcp_gbl_ctx.mctx, lease_older, active_changed,
072f0f
 			    0, &(tmp->active_timeouts)) != ISC_R_SUCCESS) {
072f0f
 		iasubopt_free_hash_table(&(tmp->leases), file, line);
072f0f
 		dfree(tmp, file, line);
072f0f
 		return ISC_R_NOMEMORY;
072f0f
 	}
072f0f
-	if (isc_heap_create(dhcp_gbl_ctx.mctx, lease_older, lease_index_changed,
072f0f
+	if (isc_heap_create(dhcp_gbl_ctx.mctx, lease_older, inactive_changed,
072f0f
 			    0, &(tmp->inactive_timeouts)) != ISC_R_SUCCESS) {
072f0f
 		isc_heap_destroy(&(tmp->active_timeouts));
072f0f
 		iasubopt_free_hash_table(&(tmp->leases), file, line);
072f0f
@@ -1045,7 +1050,7 @@ cleanup_lease6(ia_hash_t *ia_table,
072f0f
 	 * Remove the old lease from the active heap and from the hash table
072f0f
 	 * then remove the lease from the IA and clean up the IA if necessary.
072f0f
 	 */
072f0f
-	isc_heap_delete(pool->active_timeouts, test_iasubopt->heap_index);
072f0f
+	isc_heap_delete(pool->active_timeouts, test_iasubopt->active_index);
072f0f
 	pool->num_active--;
072f0f
 
072f0f
 	iasubopt_hash_delete(pool->leases, &test_iasubopt->addr,
072f0f
@@ -1110,11 +1115,11 @@ add_lease6(struct ipv6_pool *pool, struct iasubopt *lease,
072f0f
 		if ((test_iasubopt->state == FTS_ACTIVE) ||
072f0f
 		    (test_iasubopt->state == FTS_ABANDONED)) {
072f0f
 			isc_heap_delete(pool->active_timeouts,
072f0f
-					test_iasubopt->heap_index);
072f0f
+					test_iasubopt->active_index);
072f0f
 			pool->num_active--;
072f0f
 		} else {
072f0f
 			isc_heap_delete(pool->inactive_timeouts,
072f0f
-					test_iasubopt->heap_index);
072f0f
+					test_iasubopt->inactive_index);
072f0f
 			pool->num_inactive--;
072f0f
 		}
072f0f
 
072f0f
@@ -1225,14 +1230,13 @@ lease6_usable(struct iasubopt *lease) {
072f0f
 static isc_result_t
072f0f
 move_lease_to_active(struct ipv6_pool *pool, struct iasubopt *lease) {
072f0f
 	isc_result_t insert_result;
072f0f
-	int old_heap_index;
072f0f
 
072f0f
-	old_heap_index = lease->heap_index;
072f0f
 	insert_result = isc_heap_insert(pool->active_timeouts, lease);
072f0f
 	if (insert_result == ISC_R_SUCCESS) {
072f0f
        		iasubopt_hash_add(pool->leases, &lease->addr, 
072f0f
 				  sizeof(lease->addr), lease, MDL);
072f0f
-		isc_heap_delete(pool->inactive_timeouts, old_heap_index);
072f0f
+		isc_heap_delete(pool->inactive_timeouts,
072f0f
+				lease->inactive_index);
072f0f
 		pool->num_active++;
072f0f
 		pool->num_inactive--;
072f0f
 		lease->state = FTS_ACTIVE;
072f0f
@@ -1278,16 +1282,16 @@ renew_lease6(struct ipv6_pool *pool, struct iasubopt *lease) {
072f0f
 	if (lease->state == FTS_ACTIVE) {
072f0f
 		if (old_end_time <= lease->hard_lifetime_end_time) {
072f0f
 			isc_heap_decreased(pool->active_timeouts,
072f0f
-					   lease->heap_index);
072f0f
+					   lease->active_index);
072f0f
 		} else {
072f0f
 			isc_heap_increased(pool->active_timeouts,
072f0f
-					   lease->heap_index);
072f0f
+					   lease->active_index);
072f0f
 		}
072f0f
 		return ISC_R_SUCCESS;
072f0f
 	} else if (lease->state == FTS_ABANDONED) {
072f0f
 		char tmp_addr[INET6_ADDRSTRLEN];
072f0f
                 lease->state = FTS_ACTIVE;
072f0f
-                isc_heap_increased(pool->active_timeouts, lease->heap_index);
072f0f
+                isc_heap_increased(pool->active_timeouts, lease->active_index);
072f0f
 		log_info("Reclaiming previously abandoned address %s",
072f0f
 			 inet_ntop(AF_INET6, &(lease->addr), tmp_addr,
072f0f
 				   sizeof(tmp_addr)));
072f0f
@@ -1304,9 +1308,7 @@ static isc_result_t
072f0f
 move_lease_to_inactive(struct ipv6_pool *pool, struct iasubopt *lease, 
072f0f
 		       binding_state_t state) {
072f0f
 	isc_result_t insert_result;
072f0f
-	int old_heap_index;
072f0f
 
072f0f
-	old_heap_index = lease->heap_index;
072f0f
 	insert_result = isc_heap_insert(pool->inactive_timeouts, lease);
072f0f
 	if (insert_result == ISC_R_SUCCESS) {
072f0f
 #if defined (NSUPDATE)
072f0f
@@ -1325,7 +1327,7 @@ move_lease_to_inactive(struct ipv6_pool *pool, struct iasubopt *lease,
072f0f
 
072f0f
 		iasubopt_hash_delete(pool->leases, 
072f0f
 				     &lease->addr, sizeof(lease->addr), MDL);
072f0f
-		isc_heap_delete(pool->active_timeouts, old_heap_index);
072f0f
+		isc_heap_delete(pool->active_timeouts, lease->active_index);
072f0f
 		lease->state = state;
072f0f
 		pool->num_active--;
072f0f
 		pool->num_inactive++;
072f0f
@@ -1390,7 +1392,7 @@ decline_lease6(struct ipv6_pool *pool, struct iasubopt *lease) {
072f0f
 	}
072f0f
 	lease->state = FTS_ABANDONED;
072f0f
 	lease->hard_lifetime_end_time = MAX_TIME;
072f0f
-	isc_heap_decreased(pool->active_timeouts, lease->heap_index);
072f0f
+	isc_heap_decreased(pool->active_timeouts, lease->active_index);
072f0f
 	return ISC_R_SUCCESS;
072f0f
 }
072f0f
 
072f0f
@@ -1663,7 +1665,7 @@ cleanup_old_expired(struct ipv6_pool *pool) {
072f0f
 			break;
072f0f
 		}
072f0f
 
072f0f
-		isc_heap_delete(pool->inactive_timeouts, tmp->heap_index);
072f0f
+		isc_heap_delete(pool->inactive_timeouts, tmp->inactive_index);
072f0f
 		pool->num_inactive--;
072f0f
 
072f0f
 		if (tmp->ia != NULL) {