Commit be9258d1 authored by William King's avatar William King
Browse files

fixed exceptions

parent 66a6c177
......@@ -225,7 +225,8 @@ t_dns_db_load(char **av) {
if (dns_result != DNS_R_NOTFOUND) {
dns_db_detachnode(db, &nodep);
dns_rdataset_disassociate(&rdataset);
if (dns_rdataset_isassociated(&rdataset))
dns_rdataset_disassociate(&rdataset);
}
if (dns_db_iszone(db))
......@@ -898,6 +899,7 @@ t_dns_db_newversion(char **av) {
isc_result_t isc_result;
isc_mem_t *mctx;
dns_dbnode_t *nodep;
dns_dbnode_t *found_nodep;
isc_textregion_t textregion;
isc_buffer_t newname_buffer;
dns_fixedname_t dns_newname;
......@@ -988,6 +990,7 @@ t_dns_db_newversion(char **av) {
textregion.base = newtype;
textregion.length = strlen(newtype);
dns_result = dns_rdatatype_fromtext(&rdatatype, &textregion);
if (dns_result != DNS_R_SUCCESS) {
t_info("dns_rdatatype_fromtext %s failed %s\n",
newtype,
......@@ -1059,12 +1062,15 @@ t_dns_db_newversion(char **av) {
/* close and commit the version */
dns_db_closeversion(db, &nversionp, ISC_TRUE);
dns_db_detachnode(db, &nodep);
if (dns_rdataset_isassociated(&added_rdataset))
dns_rdataset_disassociate(&added_rdataset);
nodep = NULL;
/* open a new version and find the data we added */
dns_fixedname_init(&dns_foundname);
dns_rdataset_init(&found_rdataset);
nversionp = NULL;
found_nodep = NULL;
dns_db_newversion(db, &nversionp);
/* find the recently added name and rdata */
......@@ -1074,13 +1080,19 @@ t_dns_db_newversion(char **av) {
rdatatype,
0,
0,
&nodep,
&found_nodep,
dns_fixedname_name(&dns_foundname),
&found_rdataset, NULL);
&found_rdataset,
NULL);
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_detachnode(db, &found_nodep);
if (dns_rdataset_isassociated(&found_rdataset))
dns_rdataset_disassociate(&found_rdataset);
dns_db_detach(&db);
isc_mem_destroy(&mctx);
return(T_FAIL);
......@@ -1091,7 +1103,8 @@ t_dns_db_newversion(char **av) {
t_info("dns_rdataset_first failed %s\n",
dns_result_totext(dns_result));
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_detach(&db);
isc_mem_destroy(&mctx);
......@@ -1110,11 +1123,11 @@ t_dns_db_newversion(char **av) {
result = T_FAIL;
}
/* don't need these now */
dns_db_closeversion(db, &nversionp, ISC_FALSE);
dns_rdataset_disassociate(&found_rdataset);
dns_db_detachnode(db, &nodep);
if (dns_rdataset_isassociated(&found_rdataset))
dns_rdataset_disassociate(&found_rdataset);
dns_db_detachnode(db, &found_nodep);
dns_db_detach(&db);
isc_mem_destroy(&mctx);
......@@ -1403,8 +1416,13 @@ t_dns_db_closeversion_1(char **av) {
&found_rdataset, NULL);
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_detachnode(db, &nodep);
if (dns_rdataset_isassociated(&found_rdataset))
dns_rdataset_disassociate(&found_rdataset);
dns_db_detach(&db);
isc_mem_destroy(&mctx);
return(T_FAIL);
......@@ -1415,7 +1433,8 @@ t_dns_db_closeversion_1(char **av) {
t_info("dns_rdataset_first failed %s\n",
dns_result_totext(dns_result));
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_detach(&db);
isc_mem_destroy(&mctx);
......@@ -1433,7 +1452,8 @@ t_dns_db_closeversion_1(char **av) {
/* 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_db_detachnode(db, &nodep);
nodep = NULL;
......@@ -1747,8 +1767,12 @@ t_dns_db_closeversion_2(char **av) {
(dns_result == DNS_R_NXDOMAIN) ||
(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_detachnode(db, &nodep);
if (dns_rdataset_isassociated(&found_rdataset))
dns_rdataset_disassociate(&found_rdataset);
dns_db_detach(&db);
isc_mem_destroy(&mctx);
return(T_FAIL);
......@@ -1759,7 +1783,8 @@ t_dns_db_closeversion_2(char **av) {
t_info("dns_rdataset_first failed %s\n",
dns_result_totext(dns_result));
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_detach(&db);
isc_mem_destroy(&mctx);
......@@ -1777,7 +1802,8 @@ t_dns_db_closeversion_2(char **av) {
/* 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_db_detachnode(db, &nodep);
nodep = NULL;
......@@ -1797,7 +1823,8 @@ t_dns_db_closeversion_2(char **av) {
if ((dns_result != DNS_R_NOTFOUND) && (dns_result != DNS_R_NXDOMAIN)) {
t_info("dns_db_find %s returned %s\n", existing_name,
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);
++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_NXRDATASET) && (dns_result != DNS_R_ZONECUT))
dns_rdataset_disassociate(&rdataset);
if (dns_rdataset_isassociated(&rdataset))
dns_rdataset_disassociate(&rdataset);
dns_db_detachnode(db, &nodep);
}
......
......@@ -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) {
*dns_result = create_name(name, mctx, &dns_name);
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);
}
else {
t_info("dns_rbt_addname failed %s\n",
dns_result_totext(*dns_result));
delete_name(dns_name, mctx);
++nprobs;
}
}
......@@ -297,6 +302,7 @@ test_rbt_gen(char *filename, char *command, char *testname, dns_result_t exp_res
isc_result_t isc_result;
dns_result_t dns_result;
isc_mem_t *mctx;
dns_name_t *dns_name;
result = T_UNRESOLVED;
......@@ -324,28 +330,45 @@ test_rbt_gen(char *filename, char *command, char *testname, dns_result_t exp_res
result = T_PASS;
}
else if (strcmp(command, "add") == 0) {
rval = t1_add(testname, rbt, mctx, &dns_result);
if (rval == 0) {
dns_result = create_name(testname, mctx, &dns_name);
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) {
rval = t1_search(testname, rbt, mctx, &dns_result);
if (rval == 0) {
if (dns_result == DNS_R_SUCCESS) {
result = T_PASS;
if (dns_result == DNS_R_SUCCESS) {
rval = t1_search(testname, rbt, mctx, &dns_result);
if (rval == 0) {
if (dns_result == DNS_R_SUCCESS) {
result = T_PASS;
}
else {
result = T_FAIL;
}
}
else {
t_info("dns_rbt_addname didn't "
"add the name");
result = T_FAIL;
t_info("t1_search failed\n");
result = T_UNRESOLVED;
}
}
else {
result = T_PASS;
}
}
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(exp_result));
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) ||
(strcmp(command, "nuke") == 0)) {
......@@ -1459,6 +1482,7 @@ t_dns_rbtnodechain_prev(char *dbfile, char *findname,
}
/* set the starting node */
node = NULL;
dns_result = dns_rbt_findnode(rbt, dns_fixedname_name(&dns_findname),
dns_fixedname_name(&dns_foundname),
&node, &chain, ISC_TRUE, NULL, NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment