summaryrefslogtreecommitdiffstats
path: root/lib/resolve.h
diff options
context:
space:
mode:
authorVladimír Čunát <vladimir.cunat@nic.cz>2019-09-13 18:26:19 +0200
committerVladimír Čunát <vladimir.cunat@nic.cz>2020-10-21 13:05:55 +0200
commit99e014ac6352a6ded4142f3c1b9b530dc02e0baf (patch)
tree638194e70bc14be0289e86c33aaab2df39ca301c /lib/resolve.h
parentiterate nitpick: drop unused function parameter (diff)
downloadknot-resolver-99e014ac6352a6ded4142f3c1b9b530dc02e0baf.tar.xz
knot-resolver-99e014ac6352a6ded4142f3c1b9b530dc02e0baf.zip
WIP delay allocation of kr_request::answer
FIXME: see FIXMEs in diff, document the API change, re-review.
Diffstat (limited to 'lib/resolve.h')
-rw-r--r--lib/resolve.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/resolve.h b/lib/resolve.h
index db596a38..6f5de262 100644
--- a/lib/resolve.h
+++ b/lib/resolve.h
@@ -36,7 +36,7 @@
* };
*
* // Setup and provide input query
- * int state = kr_resolve_begin(&req, ctx, final_answer);
+ * int state = kr_resolve_begin(&req, ctx);
* state = kr_resolve_consume(&req, query);
*
* // Generate answer
@@ -179,7 +179,7 @@ struct kr_request_qsource_flags {
*/
struct kr_request {
struct kr_context *ctx;
- knot_pkt_t *answer;
+ knot_pkt_t *answer; /**< See kr_request_ensure_answer() */
struct kr_query *current_query; /**< Current evaluated query. */
struct {
/** Address that originated the request. NULL for internal origin. */
@@ -234,16 +234,24 @@ struct kr_request {
/**
* Begin name resolution.
*
- * @note Expects a request to have an initialized mempool, the "answer" packet will
- * be kept during the resolution and will contain the final answer at the end.
+ * @note Expects a request to have an initialized mempool.
*
* @param request request state with initialized mempool
* @param ctx resolution context
- * @param answer allocated packet for final answer
* @return CONSUME (expecting query)
*/
KR_EXPORT
-int kr_resolve_begin(struct kr_request *request, struct kr_context *ctx, knot_pkt_t *answer);
+int kr_resolve_begin(struct kr_request *request, struct kr_context *ctx);
+
+/**
+ * Ensure that request->answer is usable, and return it (for convenience).
+ *
+ * It can not fail; FIXME: is it worth in the API to abort() instead of return NULL?
+ * Only use this when it's guaranteed that there will be no delay before sending it.
+ * You don't need to call this in places where "resolver knows" that there will be no delay.
+ */
+KR_EXPORT __attribute__((returns_nonnull))
+knot_pkt_t * kr_request_ensure_answer(struct kr_request *request);
/**
* Consume input packet (may be either first query or answer to query originated from kr_resolve_produce())