2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

fixed exceptions

This commit is contained in:
William King
1999-10-15 17:07:21 +00:00
parent 66a6c17757
commit be9258d15b
2 changed files with 78 additions and 26 deletions

View File

@@ -225,7 +225,8 @@ t_dns_db_load(char **av) {
if (dns_result != DNS_R_NOTFOUND) { if (dns_result != DNS_R_NOTFOUND) {
dns_db_detachnode(db, &nodep); dns_db_detachnode(db, &nodep);
dns_rdataset_disassociate(&rdataset); if (dns_rdataset_isassociated(&rdataset))
dns_rdataset_disassociate(&rdataset);
} }
if (dns_db_iszone(db)) if (dns_db_iszone(db))
@@ -898,6 +899,7 @@ t_dns_db_newversion(char **av) {
isc_result_t isc_result; isc_result_t isc_result;
isc_mem_t *mctx; isc_mem_t *mctx;
dns_dbnode_t *nodep; dns_dbnode_t *nodep;
dns_dbnode_t *found_nodep;
isc_textregion_t textregion; isc_textregion_t textregion;
isc_buffer_t newname_buffer; isc_buffer_t newname_buffer;
dns_fixedname_t dns_newname; dns_fixedname_t dns_newname;
@@ -988,6 +990,7 @@ t_dns_db_newversion(char **av) {
textregion.base = newtype; textregion.base = newtype;
textregion.length = strlen(newtype); textregion.length = strlen(newtype);
dns_result = dns_rdatatype_fromtext(&rdatatype, &textregion); dns_result = dns_rdatatype_fromtext(&rdatatype, &textregion);
if (dns_result != DNS_R_SUCCESS) { if (dns_result != DNS_R_SUCCESS) {
t_info("dns_rdatatype_fromtext %s failed %s\n", t_info("dns_rdatatype_fromtext %s failed %s\n",
newtype, newtype,
@@ -1059,12 +1062,15 @@ t_dns_db_newversion(char **av) {
/* close and commit the version */ /* close and commit the version */
dns_db_closeversion(db, &nversionp, ISC_TRUE); dns_db_closeversion(db, &nversionp, ISC_TRUE);
dns_db_detachnode(db, &nodep); dns_db_detachnode(db, &nodep);
if (dns_rdataset_isassociated(&added_rdataset))
dns_rdataset_disassociate(&added_rdataset);
nodep = NULL; nodep = NULL;
/* open a new version and find the data we added */ /* open a new version and find the data we added */
dns_fixedname_init(&dns_foundname); dns_fixedname_init(&dns_foundname);
dns_rdataset_init(&found_rdataset); dns_rdataset_init(&found_rdataset);
nversionp = NULL; nversionp = NULL;
found_nodep = NULL;
dns_db_newversion(db, &nversionp); dns_db_newversion(db, &nversionp);
/* find the recently added name and rdata */ /* find the recently added name and rdata */
@@ -1074,13 +1080,19 @@ t_dns_db_newversion(char **av) {
rdatatype, rdatatype,
0, 0,
0, 0,
&nodep, &found_nodep,
dns_fixedname_name(&dns_foundname), dns_fixedname_name(&dns_foundname),
&found_rdataset, NULL); &found_rdataset,
NULL);
if (dns_result != DNS_R_SUCCESS) { if (dns_result != DNS_R_SUCCESS) {
t_info("unable to find %s\n", newname); /* ZZZ - NXRRSET ??? reference counts ??? */
t_info("dns_db_find failed %s\n",
dns_result_totext(dns_result));
dns_db_closeversion(db, &nversionp, ISC_FALSE); dns_db_closeversion(db, &nversionp, ISC_FALSE);
dns_db_detachnode(db, &found_nodep);
if (dns_rdataset_isassociated(&found_rdataset))
dns_rdataset_disassociate(&found_rdataset);
dns_db_detach(&db); dns_db_detach(&db);
isc_mem_destroy(&mctx); isc_mem_destroy(&mctx);
return(T_FAIL); return(T_FAIL);
@@ -1091,7 +1103,8 @@ t_dns_db_newversion(char **av) {
t_info("dns_rdataset_first failed %s\n", t_info("dns_rdataset_first failed %s\n",
dns_result_totext(dns_result)); dns_result_totext(dns_result));
dns_db_detachnode(db, &nodep); dns_db_detachnode(db, &nodep);
dns_rdataset_disassociate(&found_rdataset); if (dns_rdataset_isassociated(&found_rdataset))
dns_rdataset_disassociate(&found_rdataset);
dns_db_closeversion(db, &nversionp, ISC_FALSE); dns_db_closeversion(db, &nversionp, ISC_FALSE);
dns_db_detach(&db); dns_db_detach(&db);
isc_mem_destroy(&mctx); isc_mem_destroy(&mctx);
@@ -1110,11 +1123,11 @@ t_dns_db_newversion(char **av) {
result = T_FAIL; result = T_FAIL;
} }
/* don't need these now */ /* don't need these now */
dns_db_closeversion(db, &nversionp, ISC_FALSE); dns_db_closeversion(db, &nversionp, ISC_FALSE);
dns_rdataset_disassociate(&found_rdataset); if (dns_rdataset_isassociated(&found_rdataset))
dns_db_detachnode(db, &nodep); dns_rdataset_disassociate(&found_rdataset);
dns_db_detachnode(db, &found_nodep);
dns_db_detach(&db); dns_db_detach(&db);
isc_mem_destroy(&mctx); isc_mem_destroy(&mctx);
@@ -1403,8 +1416,13 @@ t_dns_db_closeversion_1(char **av) {
&found_rdataset, NULL); &found_rdataset, NULL);
if (dns_result != DNS_R_SUCCESS) { if (dns_result != DNS_R_SUCCESS) {
t_info("unable to find %s\n", new_name); /* ZZZ NXRRSET ??? reference counting ??? */
t_info("dns_db_find failed %s\n",
dns_result_totext(dns_result));
dns_db_closeversion(db, &cversionp, ISC_FALSE); dns_db_closeversion(db, &cversionp, ISC_FALSE);
dns_db_detachnode(db, &nodep);
if (dns_rdataset_isassociated(&found_rdataset))
dns_rdataset_disassociate(&found_rdataset);
dns_db_detach(&db); dns_db_detach(&db);
isc_mem_destroy(&mctx); isc_mem_destroy(&mctx);
return(T_FAIL); return(T_FAIL);
@@ -1415,7 +1433,8 @@ t_dns_db_closeversion_1(char **av) {
t_info("dns_rdataset_first failed %s\n", t_info("dns_rdataset_first failed %s\n",
dns_result_totext(dns_result)); dns_result_totext(dns_result));
dns_db_detachnode(db, &nodep); dns_db_detachnode(db, &nodep);
dns_rdataset_disassociate(&found_rdataset); if (dns_rdataset_isassociated(&found_rdataset))
dns_rdataset_disassociate(&found_rdataset);
dns_db_closeversion(db, &cversionp, ISC_FALSE); dns_db_closeversion(db, &cversionp, ISC_FALSE);
dns_db_detach(&db); dns_db_detach(&db);
isc_mem_destroy(&mctx); isc_mem_destroy(&mctx);
@@ -1433,7 +1452,8 @@ t_dns_db_closeversion_1(char **av) {
/* now check the rdata deletion */ /* now check the rdata deletion */
dns_rdataset_disassociate(&found_rdataset); if (dns_rdataset_isassociated(&found_rdataset))
dns_rdataset_disassociate(&found_rdataset);
dns_rdataset_init(&found_rdataset); dns_rdataset_init(&found_rdataset);
dns_db_detachnode(db, &nodep); dns_db_detachnode(db, &nodep);
nodep = NULL; nodep = NULL;
@@ -1747,8 +1767,12 @@ t_dns_db_closeversion_2(char **av) {
(dns_result == DNS_R_NXDOMAIN) || (dns_result == DNS_R_NXDOMAIN) ||
(dns_result == DNS_R_NXRDATASET)) { (dns_result == DNS_R_NXRDATASET)) {
t_info("unable to find %s\n", new_name); t_info("dns_db_find failed %s\n",
dns_result_totext(dns_result));
dns_db_closeversion(db, &nversionp, ISC_FALSE); dns_db_closeversion(db, &nversionp, ISC_FALSE);
dns_db_detachnode(db, &nodep);
if (dns_rdataset_isassociated(&found_rdataset))
dns_rdataset_disassociate(&found_rdataset);
dns_db_detach(&db); dns_db_detach(&db);
isc_mem_destroy(&mctx); isc_mem_destroy(&mctx);
return(T_FAIL); return(T_FAIL);
@@ -1759,7 +1783,8 @@ t_dns_db_closeversion_2(char **av) {
t_info("dns_rdataset_first failed %s\n", t_info("dns_rdataset_first failed %s\n",
dns_result_totext(dns_result)); dns_result_totext(dns_result));
dns_db_detachnode(db, &nodep); dns_db_detachnode(db, &nodep);
dns_rdataset_disassociate(&found_rdataset); if (dns_rdataset_isassociated(&found_rdataset))
dns_rdataset_disassociate(&found_rdataset);
dns_db_closeversion(db, &nversionp, ISC_FALSE); dns_db_closeversion(db, &nversionp, ISC_FALSE);
dns_db_detach(&db); dns_db_detach(&db);
isc_mem_destroy(&mctx); isc_mem_destroy(&mctx);
@@ -1777,7 +1802,8 @@ t_dns_db_closeversion_2(char **av) {
/* now check the rdata deletion */ /* now check the rdata deletion */
dns_rdataset_disassociate(&found_rdataset); if (dns_rdataset_isassociated(&found_rdataset))
dns_rdataset_disassociate(&found_rdataset);
dns_rdataset_init(&found_rdataset); dns_rdataset_init(&found_rdataset);
dns_db_detachnode(db, &nodep); dns_db_detachnode(db, &nodep);
nodep = NULL; nodep = NULL;
@@ -1797,7 +1823,8 @@ t_dns_db_closeversion_2(char **av) {
if ((dns_result != DNS_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { if ((dns_result != DNS_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) {
t_info("dns_db_find %s returned %s\n", existing_name, t_info("dns_db_find %s returned %s\n", existing_name,
dns_result_totext(dns_result)); dns_result_totext(dns_result));
dns_rdataset_disassociate(&found_rdataset); if (dns_rdataset_isassociated(&found_rdataset))
dns_rdataset_disassociate(&found_rdataset);
dns_db_detachnode(db, &nodep); dns_db_detachnode(db, &nodep);
++nfails; ++nfails;
} }
@@ -2529,7 +2556,8 @@ t_dns_db_find_x(char **av) {
if ((dns_result != DNS_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) { if ((dns_result != DNS_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) {
if ((dns_result != DNS_R_NXRDATASET) && (dns_result != DNS_R_ZONECUT)) if ((dns_result != DNS_R_NXRDATASET) && (dns_result != DNS_R_ZONECUT))
dns_rdataset_disassociate(&rdataset); if (dns_rdataset_isassociated(&rdataset))
dns_rdataset_disassociate(&rdataset);
dns_db_detachnode(db, &nodep); dns_db_detachnode(db, &nodep);
} }

View File

@@ -178,9 +178,14 @@ t1_add(char *name, dns_rbt_t *rbt, isc_mem_t *mctx, dns_result_t *dns_result) {
if (name && dns_result) { if (name && dns_result) {
*dns_result = create_name(name, mctx, &dns_name); *dns_result = create_name(name, mctx, &dns_name);
if (*dns_result == DNS_R_SUCCESS) { if (*dns_result == DNS_R_SUCCESS) {
if (T_debug)
t_info("dns_rbt_addname succeeded\n");
*dns_result = dns_rbt_addname(rbt, dns_name, dns_name); *dns_result = dns_rbt_addname(rbt, dns_name, dns_name);
} }
else { else {
t_info("dns_rbt_addname failed %s\n",
dns_result_totext(*dns_result));
delete_name(dns_name, mctx);
++nprobs; ++nprobs;
} }
} }
@@ -297,6 +302,7 @@ test_rbt_gen(char *filename, char *command, char *testname, dns_result_t exp_res
isc_result_t isc_result; isc_result_t isc_result;
dns_result_t dns_result; dns_result_t dns_result;
isc_mem_t *mctx; isc_mem_t *mctx;
dns_name_t *dns_name;
result = T_UNRESOLVED; result = T_UNRESOLVED;
@@ -324,28 +330,45 @@ test_rbt_gen(char *filename, char *command, char *testname, dns_result_t exp_res
result = T_PASS; result = T_PASS;
} }
else if (strcmp(command, "add") == 0) { else if (strcmp(command, "add") == 0) {
rval = t1_add(testname, rbt, mctx, &dns_result); dns_result = create_name(testname, mctx, &dns_name);
if (rval == 0) { if (dns_result == DNS_R_SUCCESS) {
dns_result = dns_rbt_addname(rbt, dns_name, dns_name);
if (dns_result != DNS_R_SUCCESS)
delete_name(dns_name, mctx);
if (dns_result == exp_result) { if (dns_result == exp_result) {
rval = t1_search(testname, rbt, mctx, &dns_result); if (dns_result == DNS_R_SUCCESS) {
if (rval == 0) { rval = t1_search(testname, rbt, mctx, &dns_result);
if (dns_result == DNS_R_SUCCESS) { if (rval == 0) {
result = T_PASS; if (dns_result == DNS_R_SUCCESS) {
result = T_PASS;
}
else {
result = T_FAIL;
}
} }
else { else {
t_info("dns_rbt_addname didn't " t_info("t1_search failed\n");
"add the name"); result = T_UNRESOLVED;
result = T_FAIL;
} }
} }
else {
result = T_PASS;
}
} }
else { else {
t_info("add returned %s, expected %s\n", t_info("dns_rbt_addname returned %s, expected %s\n",
dns_result_totext(dns_result), dns_result_totext(dns_result),
dns_result_totext(exp_result)); dns_result_totext(exp_result));
result = T_FAIL; result = T_FAIL;
} }
} }
else {
t_info("create_name failed %s\n",
dns_result_totext(dns_result));
result = T_UNRESOLVED;
}
} }
else if ((strcmp(command, "delete") == 0) || else if ((strcmp(command, "delete") == 0) ||
(strcmp(command, "nuke") == 0)) { (strcmp(command, "nuke") == 0)) {
@@ -1459,6 +1482,7 @@ t_dns_rbtnodechain_prev(char *dbfile, char *findname,
} }
/* set the starting node */ /* set the starting node */
node = NULL;
dns_result = dns_rbt_findnode(rbt, dns_fixedname_name(&dns_findname), dns_result = dns_rbt_findnode(rbt, dns_fixedname_name(&dns_findname),
dns_fixedname_name(&dns_foundname), dns_fixedname_name(&dns_foundname),
&node, &chain, ISC_TRUE, NULL, NULL); &node, &chain, ISC_TRUE, NULL, NULL);