2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

further incremental iterator support

This commit is contained in:
Bob Halley
1999-04-19 22:53:33 +00:00
parent d25999ff03
commit d41e7a38de

View File

@@ -61,6 +61,9 @@ typedef struct dbinfo {
int rcount; int rcount;
dns_dbnode_t * hold_nodes[MAXHOLD]; dns_dbnode_t * hold_nodes[MAXHOLD];
int hold_count; int hold_count;
dns_dbiterator_t * dbiterator;
dns_dbversion_t * iversion;
int pause_every;
ISC_LINK(struct dbinfo) link; ISC_LINK(struct dbinfo) link;
} dbinfo; } dbinfo;
@@ -144,38 +147,39 @@ static void
dump(dbinfo *dbi) { dump(dbinfo *dbi) {
dns_fixedname_t fname; dns_fixedname_t fname;
dns_name_t *name; dns_name_t *name;
dns_dbiterator_t *dbiterator;
dns_dbnode_t *node; dns_dbnode_t *node;
dns_rdatasetiter_t *rdsiter; dns_rdatasetiter_t *rdsiter;
dns_dbversion_t *version;
dns_result_t result; dns_result_t result;
isc_boolean_t close_version = ISC_FALSE;
int i; int i;
if (dns_db_iszone(dbi->db)) { dns_fixedname_init(&fname);
if (dbi->version != NULL) name = dns_fixedname_name(&fname);
version = dbi->version;
else { if (dbi->dbiterator == NULL) {
dns_db_currentversion(dbi->db, &version); INSIST(dbi->iversion == NULL);
close_version = ISC_TRUE; if (dns_db_iszone(dbi->db)) {
if (dbi->version != NULL)
dns_db_attachversion(dbi->db, dbi->version,
&dbi->iversion);
else
dns_db_currentversion(dbi->db, &dbi->iversion);
} }
} else
version = NULL;
dbiterator = NULL; result = dns_db_createiterator(dbi->db, ISC_FALSE,
dns_db_createiterator(dbi->db, ISC_FALSE, &dbiterator); &dbi->dbiterator);
if (result == DNS_R_SUCCESS)
result = dns_dbiterator_first(dbi->dbiterator);
} else
result = DNS_R_SUCCESS;
node = NULL; node = NULL;
rdsiter = NULL; rdsiter = NULL;
dns_fixedname_init(&fname);
name = dns_fixedname_name(&fname);
result = dns_dbiterator_first(dbiterator);
i = 0; i = 0;
while (result == DNS_R_SUCCESS) { while (result == DNS_R_SUCCESS) {
result = dns_dbiterator_current(dbiterator, &node, name); result = dns_dbiterator_current(dbi->dbiterator, &node, name);
if (result != DNS_R_SUCCESS && result != DNS_R_NEWORIGIN) if (result != DNS_R_SUCCESS && result != DNS_R_NEWORIGIN)
break; break;
result = dns_db_allrdatasets(dbi->db, node, version, 0, result = dns_db_allrdatasets(dbi->db, node, dbi->iversion, 0,
&rdsiter); &rdsiter);
if (result != DNS_R_SUCCESS) { if (result != DNS_R_SUCCESS) {
dns_db_detachnode(dbi->db, &node); dns_db_detachnode(dbi->db, &node);
@@ -184,21 +188,21 @@ dump(dbinfo *dbi) {
print_rdatasets(name, rdsiter); print_rdatasets(name, rdsiter);
dns_rdatasetiter_destroy(&rdsiter); dns_rdatasetiter_destroy(&rdsiter);
dns_db_detachnode(dbi->db, &node); dns_db_detachnode(dbi->db, &node);
result = dns_dbiterator_next(dbi->dbiterator);
i++; i++;
if (i == pause_every) { if (result == DNS_R_SUCCESS && i == dbi->pause_every) {
result = dns_dbiterator_pause(dbiterator); printf("[more...]\n");
if (result != DNS_R_SUCCESS) result = dns_dbiterator_pause(dbi->dbiterator);
break; if (result == DNS_R_SUCCESS)
i = 0; return;
} }
result = dns_dbiterator_next(dbiterator);
} }
if (result != DNS_R_NOMORE) if (result != DNS_R_NOMORE)
printf("%s\n", dns_result_totext(result)); printf("%s\n", dns_result_totext(result));
dns_dbiterator_destroy(&dbiterator); dns_dbiterator_destroy(&dbi->dbiterator);
if (close_version) if (dbi->iversion != NULL)
dns_db_closeversion(dbi->db, &version, ISC_FALSE); dns_db_closeversion(dbi->db, &dbi->iversion, ISC_FALSE);
} }
static dns_result_t static dns_result_t
@@ -223,6 +227,9 @@ load(char *filename, char *origintext, isc_boolean_t cache) {
dbi->hold_count = 0; dbi->hold_count = 0;
for (i = 0; i < MAXHOLD; i++) for (i = 0; i < MAXHOLD; i++)
dbi->hold_nodes[i] = NULL; dbi->hold_nodes[i] = NULL;
dbi->dbiterator = NULL;
dbi->iversion = NULL;
dbi->pause_every = pause_every;
len = strlen(origintext); len = strlen(origintext);
isc_buffer_init(&source, origintext, len, ISC_BUFFERTYPE_TEXT); isc_buffer_init(&source, origintext, len, ISC_BUFFERTYPE_TEXT);
@@ -575,6 +582,11 @@ main(int argc, char *argv[]) {
DBI_CHECK(dbi); DBI_CHECK(dbi);
dump(dbi); dump(dbi);
continue; continue;
} else if (strstr(s, "!P") == s) {
DBI_CHECK(dbi);
v = atoi(&s[2]);
dbi->pause_every = v;
continue;
} else if (strcmp(s, "!DB") == 0) { } else if (strcmp(s, "!DB") == 0) {
dbi = NULL; dbi = NULL;
origin = dns_rootname; origin = dns_rootname;