Commit 7a996f0c authored by Michał Kępień's avatar Michał Kępień

Do not call exit() upon is_empty() errors

Replace the check_result() call inside is_empty() with a
zoneverify_log_error() call and error handling code.  Enable is_empty()
to signal errors to the caller using its return value.

Modify the call site of is_empty() so that its errors are properly
handled.
parent 04038baf
...@@ -862,18 +862,23 @@ verifynode(vctx_t *vctx, dns_name_t *name, dns_dbnode_t *node, ...@@ -862,18 +862,23 @@ verifynode(vctx_t *vctx, dns_name_t *name, dns_dbnode_t *node,
return (result); return (result);
} }
static isc_boolean_t static isc_result_t
is_empty(const vctx_t *vctx, dns_dbnode_t *node) { is_empty(const vctx_t *vctx, dns_dbnode_t *node, isc_boolean_t *empty) {
dns_rdatasetiter_t *rdsiter = NULL; dns_rdatasetiter_t *rdsiter = NULL;
isc_result_t result; isc_result_t result;
result = dns_db_allrdatasets(vctx->db, node, vctx->ver, 0, &rdsiter); result = dns_db_allrdatasets(vctx->db, node, vctx->ver, 0, &rdsiter);
check_result(result, "dns_db_allrdatasets()"); if (result != ISC_R_SUCCESS) {
zoneverify_log_error(vctx, "dns_db_allrdatasets(): %s",
isc_result_totext(result));
return (result);
}
result = dns_rdatasetiter_first(rdsiter); result = dns_rdatasetiter_first(rdsiter);
dns_rdatasetiter_destroy(&rdsiter); dns_rdatasetiter_destroy(&rdsiter);
if (result == ISC_R_NOMORE)
return (ISC_TRUE); *empty = ISC_TF(result == ISC_R_NOMORE);
return (ISC_FALSE);
return (ISC_R_SUCCESS);
} }
static isc_result_t static isc_result_t
...@@ -1494,6 +1499,7 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) { ...@@ -1494,6 +1499,7 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) {
nextnode = NULL; nextnode = NULL;
result = dns_dbiterator_next(dbiter); result = dns_dbiterator_next(dbiter);
while (result == ISC_R_SUCCESS) { while (result == ISC_R_SUCCESS) {
isc_boolean_t empty;
result = dns_dbiterator_current(dbiter, &nextnode, result = dns_dbiterator_current(dbiter, &nextnode,
nextname); nextname);
if (result != ISC_R_SUCCESS && if (result != ISC_R_SUCCESS &&
...@@ -1521,12 +1527,16 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) { ...@@ -1521,12 +1527,16 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) {
result = dns_dbiterator_next(dbiter); result = dns_dbiterator_next(dbiter);
continue; continue;
} }
if (is_empty(vctx, nextnode)) { result = is_empty(vctx, nextnode, &empty);
dns_db_detachnode(vctx->db, &nextnode); dns_db_detachnode(vctx->db, &nextnode);
if (result != ISC_R_SUCCESS) {
dns_db_detachnode(vctx->db, &node);
goto done;
}
if (empty) {
result = dns_dbiterator_next(dbiter); result = dns_dbiterator_next(dbiter);
continue; continue;
} }
dns_db_detachnode(vctx->db, &nextnode);
break; break;
} }
if (result == ISC_R_NOMORE) { if (result == ISC_R_NOMORE) {
......
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