Commit a02f4411 authored by Vladimír Čunát's avatar Vladimír Čunát Committed by Petr Špaček

lua: fix a mistake in kr_query, and simplify serve_stale

Fields after kr_nsrep got offset; fortunately only new fields were
added in there, unused from lua so far.
parent 40fd60ce
......@@ -3,7 +3,7 @@ MAJOR := 2
MINOR := 0
PATCH := 0
EXTRA :=
ABIVER := 5
ABIVER := 6
BUILDMODE := dynamic
HARDENING := yes
......
......@@ -201,7 +201,7 @@ struct kr_nsrep {
unsigned int reputation;
const knot_dname_t *name;
struct kr_context *ctx;
/* beware: hidden stub */
/* beware: hidden stub, to avoid hardcoding sockaddr lengths */
};
struct kr_query {
struct kr_query *parent;
......@@ -218,12 +218,12 @@ struct kr_query {
uint64_t timestamp_mono;
struct timeval timestamp;
struct kr_zonecut zone_cut;
struct kr_nsrep ns;
struct kr_layer_pickle *deferred;
uint32_t uid;
struct kr_query *cname_parent;
struct kr_request *request;
kr_stale_cb stale_cb;
struct kr_nsrep ns;
};
struct kr_context {
struct kr_qflags options;
......@@ -286,7 +286,6 @@ struct sockaddr *kr_straddr_socket(const char *, int);
int kr_ranked_rrarray_add(ranked_rr_array_t *, const knot_rrset_t *, uint8_t, _Bool, uint32_t, knot_mm_t *);
void kr_qflags_set(struct kr_qflags *, struct kr_qflags);
void kr_qflags_clear(struct kr_qflags *, struct kr_qflags);
void kr_query_set_stale_cb(struct kr_query *, kr_stale_cb);
int kr_zonecut_add(struct kr_zonecut *, const knot_dname_t *, const knot_rdata_t *);
void kr_zonecut_set(struct kr_zonecut *, const knot_dname_t *);
uint64_t kr_now();
......
......@@ -80,7 +80,7 @@ genResType "struct knot_rrset" | sed 's/\<owner\>/_owner/'
## Some definitions would need too many deps, so shorten them.
genResType "struct kr_nsrep" | sed '/union/,$ d'
printf "\t/* beware: hidden stub */\n};\n"
printf "\t/* beware: hidden stub, to avoid hardcoding sockaddr lengths */\n};\n"
genResType "struct kr_query"
......@@ -153,7 +153,6 @@ EOF
kr_ranked_rrarray_add
kr_qflags_set
kr_qflags_clear
kr_query_set_stale_cb
kr_zonecut_add
kr_zonecut_set
kr_now
......
......@@ -27,11 +27,6 @@
#define QUERY_PROVIDES(q, name, cls, type) \
((q)->sclass == (cls) && (q)->stype == type && knot_dname_is_equal((q)->sname, name))
void kr_query_set_stale_cb(struct kr_query *qry, kr_stale_cb cb)
{
qry->stale_cb = cb;
}
inline static unsigned char chars_or(const unsigned char a, const unsigned char b)
{
return a | b;
......
......@@ -78,10 +78,6 @@ void kr_qflags_clear(struct kr_qflags *fl1, struct kr_qflags fl2);
*/
typedef int32_t (*kr_stale_cb)(int32_t ttl, const knot_dname_t *owner, uint16_t type,
const struct kr_query *qry);
/** Trivial wrapper to set kr_query::stale_cb.
* For some unknown reason, direct setting via lua doesn't work. */
KR_EXPORT
void kr_query_set_stale_cb(struct kr_query *qry, kr_stale_cb cb);
/**
* Single query representation.
......@@ -103,13 +99,14 @@ struct kr_query {
* query to upstream resolver (milliseconds). */
struct timeval timestamp; /**< Real time for TTL+DNSSEC checks (.tv_sec only). */
struct kr_zonecut zone_cut;
struct kr_nsrep ns;
struct kr_layer_pickle *deferred;
uint32_t uid; /**< Query iteration number, unique within the kr_rplan. */
/** Pointer to the query that originated this one because of following a CNAME (or NULL). */
struct kr_query *cname_parent;
struct kr_request *request; /**< Parent resolution request. */
kr_stale_cb stale_cb; /**< See the type */
/* Beware: this must remain the last, because of lua bindings. */
struct kr_nsrep ns;
};
/** @cond internal Array of queries. */
......
......@@ -28,7 +28,7 @@ M.layer = {
local deadline = qry.creation_time_mono + M.timeout
if now > deadline then
--log('[ ][stal] => deadline has passed')
ffi.C.kr_query_set_stale_cb(qry, M.callback)
qry.stale_cb = M.callback
-- TODO: probably start the same request that doesn't stale-serve,
-- but first we need some detection of non-interactive / internal requests.
-- resolve(kres.dname2str(qry.sname), qry.stype, qry.sclass)
......
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