Skip to content
Snippets Groups Projects
Commit ca2d4fe8 authored by Marek Vavruša's avatar Marek Vavruša
Browse files

daemon: send back error responses

parent 694da3e3
Branches
Tags
No related merge requests found
......@@ -89,9 +89,5 @@ int worker_exec(struct worker_ctx *worker, knot_pkt_t *answer, knot_pkt_t *query
/* Cleanup. */
knot_layer_finish(&proc);
if (state == KNOT_NS_PROC_FAIL) {
return KNOT_ERROR;
}
return KNOT_EOK;
}
......@@ -76,6 +76,11 @@ static int iterate(struct knot_requestor *requestor, struct kr_layer_param *para
/* Resolve and check status. */
ret = knot_requestor_exec(requestor, &timeout);
if (ret != KNOT_EOK) {
/* Check if any query is left. */
cur = kr_rplan_current(rplan);
if (cur == NULL) {
return ret;
}
/* Network error, retry over TCP. */
if (ret != KNOT_LAYER_ERROR && !(cur->flags & QUERY_TCP)) {
cur->flags |= QUERY_TCP;
......@@ -109,6 +114,13 @@ static int resolve_iterative(struct kr_layer_param *param, mm_ctx_t *pool)
}
}
/* Set RCODE on internal failure. */
if (ret != KNOT_EOK) {
if (knot_wire_get_rcode(param->answer->wire) == KNOT_RCODE_NOERROR) {
knot_wire_set_rcode(param->answer->wire, KNOT_RCODE_SERVFAIL);
}
}
knot_requestor_clear(&requestor);
return ret;
}
......@@ -140,17 +152,13 @@ int kr_resolve(struct kr_context* ctx, knot_pkt_t *answer,
}
/* Check flags. */
knot_wire_set_qr(answer->wire);
knot_wire_clear_aa(answer->wire);
knot_wire_set_ra(answer->wire);
/* Resolution success, commit cache transaction. */
if (ret == KNOT_EOK) {
kr_rplan_txn_commit(&rplan);
} else {
/* Set RCODE on internal failure. */
if (knot_wire_get_rcode(answer->wire) == KNOT_RCODE_NOERROR) {
knot_wire_set_rcode(answer->wire, KNOT_RCODE_SERVFAIL);
}
}
/* Clean up. */
......
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