Commit 456e5446 authored by Marek Vavruša's avatar Marek Vavruša Committed by Marek Vavruša

all: ported to upcoming libknot APIs

this is not going to be backwards compatible change, but it will be the first tagged libknot release sufficient for resolver
parent 3bbdca30
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "contrib/base32hex.h"
#include <stdlib.h>
#include <stdint.h>
/*! \brief Maximal length of binary input to Base32hex encoding. */
#define MAX_BIN_DATA_LEN ((INT32_MAX / 8) * 5)
/*! \brief Base32hex padding character. */
const uint8_t base32hex_pad = '=';
/*! \brief Base32hex alphabet. */
const uint8_t base32hex_enc[] = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
/*! \brief Indicates bad Base32hex character. */
#define KO 255
/*! \brief Indicates Base32hex padding character. */
#define PD 32
/*! \brief Transformation and validation table for decoding Base32hex. */
const uint8_t base32hex_dec[256] = {
[ 0] = KO, [ 43] = KO, ['V'] = 31, [129] = KO, [172] = KO, [215] = KO,
[ 1] = KO, [ 44] = KO, ['W'] = KO, [130] = KO, [173] = KO, [216] = KO,
[ 2] = KO, [ 45] = KO, ['X'] = KO, [131] = KO, [174] = KO, [217] = KO,
[ 3] = KO, [ 46] = KO, ['Y'] = KO, [132] = KO, [175] = KO, [218] = KO,
[ 4] = KO, [ 47] = KO, ['Z'] = KO, [133] = KO, [176] = KO, [219] = KO,
[ 5] = KO, ['0'] = 0, [ 91] = KO, [134] = KO, [177] = KO, [220] = KO,
[ 6] = KO, ['1'] = 1, [ 92] = KO, [135] = KO, [178] = KO, [221] = KO,
[ 7] = KO, ['2'] = 2, [ 93] = KO, [136] = KO, [179] = KO, [222] = KO,
[ 8] = KO, ['3'] = 3, [ 94] = KO, [137] = KO, [180] = KO, [223] = KO,
[ 9] = KO, ['4'] = 4, [ 95] = KO, [138] = KO, [181] = KO, [224] = KO,
[ 10] = KO, ['5'] = 5, [ 96] = KO, [139] = KO, [182] = KO, [225] = KO,
[ 11] = KO, ['6'] = 6, ['a'] = 10, [140] = KO, [183] = KO, [226] = KO,
[ 12] = KO, ['7'] = 7, ['b'] = 11, [141] = KO, [184] = KO, [227] = KO,
[ 13] = KO, ['8'] = 8, ['c'] = 12, [142] = KO, [185] = KO, [228] = KO,
[ 14] = KO, ['9'] = 9, ['d'] = 13, [143] = KO, [186] = KO, [229] = KO,
[ 15] = KO, [ 58] = KO, ['e'] = 14, [144] = KO, [187] = KO, [230] = KO,
[ 16] = KO, [ 59] = KO, ['f'] = 15, [145] = KO, [188] = KO, [231] = KO,
[ 17] = KO, [ 60] = KO, ['g'] = 16, [146] = KO, [189] = KO, [232] = KO,
[ 18] = KO, ['='] = PD, ['h'] = 17, [147] = KO, [190] = KO, [233] = KO,
[ 19] = KO, [ 62] = KO, ['i'] = 18, [148] = KO, [191] = KO, [234] = KO,
[ 20] = KO, [ 63] = KO, ['j'] = 19, [149] = KO, [192] = KO, [235] = KO,
[ 21] = KO, [ 64] = KO, ['k'] = 20, [150] = KO, [193] = KO, [236] = KO,
[ 22] = KO, ['A'] = 10, ['l'] = 21, [151] = KO, [194] = KO, [237] = KO,
[ 23] = KO, ['B'] = 11, ['m'] = 22, [152] = KO, [195] = KO, [238] = KO,
[ 24] = KO, ['C'] = 12, ['n'] = 23, [153] = KO, [196] = KO, [239] = KO,
[ 25] = KO, ['D'] = 13, ['o'] = 24, [154] = KO, [197] = KO, [240] = KO,
[ 26] = KO, ['E'] = 14, ['p'] = 25, [155] = KO, [198] = KO, [241] = KO,
[ 27] = KO, ['F'] = 15, ['q'] = 26, [156] = KO, [199] = KO, [242] = KO,
[ 28] = KO, ['G'] = 16, ['r'] = 27, [157] = KO, [200] = KO, [243] = KO,
[ 29] = KO, ['H'] = 17, ['s'] = 28, [158] = KO, [201] = KO, [244] = KO,
[ 30] = KO, ['I'] = 18, ['t'] = 29, [159] = KO, [202] = KO, [245] = KO,
[ 31] = KO, ['J'] = 19, ['u'] = 30, [160] = KO, [203] = KO, [246] = KO,
[ 32] = KO, ['K'] = 20, ['v'] = 31, [161] = KO, [204] = KO, [247] = KO,
[ 33] = KO, ['L'] = 21, ['w'] = KO, [162] = KO, [205] = KO, [248] = KO,
[ 34] = KO, ['M'] = 22, ['x'] = KO, [163] = KO, [206] = KO, [249] = KO,
[ 35] = KO, ['N'] = 23, ['y'] = KO, [164] = KO, [207] = KO, [250] = KO,
[ 36] = KO, ['O'] = 24, ['z'] = KO, [165] = KO, [208] = KO, [251] = KO,
[ 37] = KO, ['P'] = 25, [123] = KO, [166] = KO, [209] = KO, [252] = KO,
[ 38] = KO, ['Q'] = 26, [124] = KO, [167] = KO, [210] = KO, [253] = KO,
[ 39] = KO, ['R'] = 27, [125] = KO, [168] = KO, [211] = KO, [254] = KO,
[ 40] = KO, ['S'] = 28, [126] = KO, [169] = KO, [212] = KO, [255] = KO,
[ 41] = KO, ['T'] = 29, [127] = KO, [170] = KO, [213] = KO,
[ 42] = KO, ['U'] = 30, [128] = KO, [171] = KO, [214] = KO,
};
int32_t base32hex_decode(const uint8_t *in,
const uint32_t in_len,
uint8_t *out,
const uint32_t out_len)
{
// Checking inputs.
if (in == NULL || out == NULL) {
return -1;
}
if (in_len > INT32_MAX || out_len < ((in_len + 7) / 8) * 5) {
return -1;
}
if ((in_len % 8) != 0) {
return -1;
}
const uint8_t *stop = in + in_len;
uint8_t *bin = out;
uint8_t pad_len = 0;
uint8_t c1, c2, c3, c4, c5, c6, c7, c8;
// Decoding loop takes 8 characters and creates 5 bytes.
while (in < stop) {
// Filling and transforming 8 Base32hex chars.
c1 = base32hex_dec[in[0]];
c2 = base32hex_dec[in[1]];
c3 = base32hex_dec[in[2]];
c4 = base32hex_dec[in[3]];
c5 = base32hex_dec[in[4]];
c6 = base32hex_dec[in[5]];
c7 = base32hex_dec[in[6]];
c8 = base32hex_dec[in[7]];
// Check 8. char if is bad or padding.
if (c8 >= PD) {
if (c8 == PD && pad_len == 0) {
pad_len = 1;
} else {
return -1;
}
}
// Check 7. char if is bad or padding (if so, 6. must be too).
if (c7 >= PD) {
if (c7 == PD && c6 == PD && pad_len == 1) {
pad_len = 3;
} else {
return -1;
}
}
// Check 6. char if is bad or padding.
if (c6 >= PD) {
if (!(c6 == PD && pad_len == 3)) {
return -1;
}
}
// Check 5. char if is bad or padding.
if (c5 >= PD) {
if (c5 == PD && pad_len == 3) {
pad_len = 4;
} else {
return -1;
}
}
// Check 4. char if is bad or padding (if so, 3. must be too).
if (c4 >= PD) {
if (c4 == PD && c3 == PD && pad_len == 4) {
pad_len = 6;
} else {
return -1;
}
}
// Check 3. char if is bad or padding.
if (c3 >= PD) {
if (!(c3 == PD && pad_len == 6)) {
return -1;
}
}
// 1. and 2. chars must not be padding.
if (c2 >= PD || c1 >= PD) {
return -1;
}
// Computing of output data based on padding length.
switch (pad_len) {
case 0:
bin[4] = (c7 << 5) + c8;
case 1:
bin[3] = (c5 << 7) + (c6 << 2) + (c7 >> 3);
case 3:
bin[2] = (c4 << 4) + (c5 >> 1);
case 4:
bin[1] = (c2 << 6) + (c3 << 1) + (c4 >> 4);
case 6:
bin[0] = (c1 << 3) + (c2 >> 2);
}
// Update output end.
switch (pad_len) {
case 0:
bin += 5;
break;
case 1:
bin += 4;
break;
case 3:
bin += 3;
break;
case 4:
bin += 2;
break;
case 6:
bin += 1;
break;
}
in += 8;
}
return (bin - out);
}
/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -13,15 +13,40 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file
*
* \brief Base32hex implementation (RFC 4648).
*
* \note Input Base32hex string can contain a-v characters. These characters
* are considered as A-V equivalent.
*
* \addtogroup contrib
* @{
*/
#pragma once
#include <libknot/packet/pkt.h>
#include <stdint.h>
/**
* Check whether packet contains given type.
* @param pkt Packet to seek through.
* @param type RR type to search for.
* @return True if found.
/*!
* \brief Decodes text data using Base32hex.
*
* \note Input data needn't be terminated with '\0'.
*
* \note Input data must be continuous Base32hex string!
*
* \param in Input text data.
* \param in_len Length of input string.
* \param out Output data buffer.
* \param out_len Size of output buffer.
*
* \retval >=0 length of output data.
* \retval KNOT_E* if error.
*/
bool _knot_pkt_has_type(const knot_pkt_t *pkt, uint16_t type);
int32_t base32hex_decode(const uint8_t *in,
const uint32_t in_len,
uint8_t *out,
const uint32_t out_len);
/*! @} */
......@@ -4,7 +4,8 @@ contrib_SOURCES := \
contrib/ccan/isaac/isaac.c \
contrib/ccan/json/json.c \
contrib/ucw/mempool.c \
contrib/murmurhash3/murmurhash3.c
contrib/murmurhash3/murmurhash3.c \
contrib/base32hex.c
contrib_CFLAGS := -fPIC
contrib_TARGET := $(abspath contrib)/contrib$(AREXT)
$(eval $(call make_static,contrib,contrib))
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file
*
* \brief Wire integer operations.
*
* \addtogroup contrib
* @{
*/
#pragma once
#include <stdint.h>
#include <string.h>
#if defined(__linux__)
# include <endian.h>
# ifndef be64toh
# include <arpa/inet.h>
# include <byteswap.h>
# if BYTE_ORDER == LITTLE_ENDIAN
# define be16toh(x) ntohs(x)
# define be32toh(x) ntohl(x)
# define be64toh(x) bswap_64 (x)
# define le16toh(x) (x)
# define le32toh(x) (x)
# define le64toh(x) (x)
# else
# define be16toh(x) (x)
# define be32toh(x) (x)
# define be64toh(x) (x)
# define le16toh(x) ntohs(x)
# define le32toh(x) ntohl(x)
# define le64toh(x) bswap_64 (x)
# endif
# endif
#elif defined(__FreeBSD__) || defined(__NetBSD__)
# include <sys/endian.h>
#elif defined(__OpenBSD__)
# include <endian.h>
#elif defined(__APPLE__)
# include <libkern/OSByteOrder.h>
# define be16toh(x) OSSwapBigToHostInt16(x)
# define be32toh(x) OSSwapBigToHostInt32(x)
# define be64toh(x) OSSwapBigToHostInt64(x)
# define htobe16(x) OSSwapHostToBigInt16(x)
# define htobe32(x) OSSwapHostToBigInt32(x)
# define htobe64(x) OSSwapHostToBigInt64(x)
# define le16toh(x) OSSwapLittleToHostInt16(x)
# define le32toh(x) OSSwapLittleToHostInt32(x)
# define le64toh(x) OSSwapLittleToHostInt64(x)
# define htole16(x) OSSwapHostToLittleInt16(x)
# define htole32(x) OSSwapHostToLittleInt32(x)
# define htole64(x) OSSwapHostToLittleInt64(x)
#endif
/*!
* \brief Reads 2 bytes from the wireformat data.
*
* \param pos Data to read the 2 bytes from.
*
* \return The 2 bytes read, in host byte order.
*/
inline static uint16_t wire_read_u16(const uint8_t *pos)
{
return be16toh(*(uint16_t *)pos);
}
/*!
* \brief Reads 4 bytes from the wireformat data.
*
* \param pos Data to read the 4 bytes from.
*
* \return The 4 bytes read, in host byte order.
*/
inline static uint32_t wire_read_u32(const uint8_t *pos)
{
return be32toh(*(uint32_t *)pos);
}
/*!
* \brief Reads 6 bytes from the wireformat data.
*
* \param pos Data to read the 6 bytes from.
*
* \return The 6 bytes read, in host byte order.
*/
inline static uint64_t wire_read_u48(const uint8_t *pos)
{
uint64_t input = 0;
memcpy((uint8_t *)&input + 1, pos, 6);
return be64toh(input) >> 8;
}
/*!
* \brief Read 8 bytes from the wireformat data.
*
* \param pos Data to read the 8 bytes from.
*
* \return The 8 bytes read, in host byte order.
*/
inline static uint64_t wire_read_u64(const uint8_t *pos)
{
return be64toh(*(uint64_t *)pos);
}
/*!
* \brief Writes 2 bytes in wireformat.
*
* The data are stored in network byte order (big endian).
*
* \param pos Position where to put the 2 bytes.
* \param data Data to put.
*/
inline static void wire_write_u16(uint8_t *pos, uint16_t data)
{
*(uint16_t *)pos = htobe16(data);
}
/*!
* \brief Writes 4 bytes in wireformat.
*
* The data are stored in network byte order (big endian).
*
* \param pos Position where to put the 4 bytes.
* \param data Data to put.
*/
inline static void wire_write_u32(uint8_t *pos, uint32_t data)
{
*(uint32_t *)pos = htobe32(data);
}
/*!
* \brief Writes 6 bytes in wireformat.
*
* The data are stored in network byte order (big endian).
*
* \param pos Position where to put the 4 bytes.
* \param data Data to put.
*/
inline static void wire_write_u48(uint8_t *pos, uint64_t data)
{
uint64_t swapped = htobe64(data << 8);
memcpy(pos, (uint8_t *)&swapped + 1, 6);
}
/*!
* \brief Writes 8 bytes in wireformat.
*
* The data are stored in network byte order (big endian).
*
* \param pos Position where to put the 8 bytes.
* \param data Data to put.
*/
inline static void wire_write_u64(uint8_t *pos, uint64_t data)
{
*(uint64_t *)pos = htobe64(data);
}
/*! @} */
......@@ -14,6 +14,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <uv.h>
#include <contrib/cleanup.h>
#include <libknot/descriptor.h>
......@@ -334,11 +335,11 @@ static int cache_backends(lua_State *L)
static int cache_count(lua_State *L)
{
struct engine *engine = engine_luaget(L);
const namedb_api_t *storage = engine->resolver.cache.api;
const knot_db_api_t *storage = engine->resolver.cache.api;
/* Fetch item count */
struct kr_cache_txn txn;
int ret = kr_cache_txn_begin(&engine->resolver.cache, &txn, NAMEDB_RDONLY);
int ret = kr_cache_txn_begin(&engine->resolver.cache, &txn, KNOT_DB_RDONLY);
if (ret != 0) {
format_error(L, kr_strerror(ret));
lua_error(L);
......
......@@ -21,9 +21,8 @@
#include <unistd.h>
#include <grp.h>
#include <pwd.h>
#include <libknot/internal/mempattern.h>
/* #include <libknot/internal/namedb/namedb_trie.h> @todo Not supported (doesn't keep value copy) */
#include <libknot/internal/namedb/namedb_lmdb.h>
/* #include <libknot/internal/namedb/knot_db_trie.h> @todo Not supported (doesn't keep value copy) */
#include <libknot/db/db_lmdb.h>
#include "daemon/engine.h"
#include "daemon/bindings.h"
......@@ -177,7 +176,7 @@ static int l_option(lua_State *L)
unsigned opt_code = 0;
if (lua_isstring(L, 1)) {
const char *opt = lua_tostring(L, 1);
for (const lookup_table_t *it = kr_query_flag_names(); it->name; ++it) {
for (const knot_lookup_t *it = kr_query_flag_names(); it->name; ++it) {
if (strcmp(it->name, opt) == 0) {
opt_code = it->id;
break;
......@@ -320,9 +319,9 @@ static int l_trampoline(lua_State *L)
*/
/** @internal Make lmdb options. */
void *namedb_lmdb_mkopts(const char *conf, size_t maxsize)
void *knot_db_lmdb_mkopts(const char *conf, size_t maxsize)
{
struct namedb_lmdb_opts *opts = malloc(sizeof(*opts));
struct knot_db_lmdb_opts *opts = malloc(sizeof(*opts));
if (opts) {
memset(opts, 0, sizeof(*opts));
opts->path = (conf && strlen(conf)) ? conf : ".";
......@@ -366,7 +365,7 @@ static int init_resolver(struct engine *engine)
/* Initialize storage backends */
struct storage_api lmdb = {
"lmdb://", namedb_lmdb_api, namedb_lmdb_mkopts
"lmdb://", knot_db_lmdb_api, knot_db_lmdb_mkopts
};
return array_push(engine->storage_registry, lmdb);
......@@ -406,7 +405,7 @@ static int init_state(struct engine *engine)
return kr_ok();
}
int engine_init(struct engine *engine, mm_ctx_t *pool)
int engine_init(struct engine *engine, knot_mm_t *pool)
{
if (engine == NULL) {
return kr_error(EINVAL);
......
......@@ -35,13 +35,14 @@
*/
struct lua_State;
#include "lib/utils.h"
#include "lib/resolve.h"
#include "daemon/network.h"
/** Cache storage backend. */
struct storage_api {
const char *prefix; /**< Storage prefix, e.g. 'lmdb://' */
const namedb_api_t *(*api)(void); /**< Storage API implementation */
const knot_db_api_t *(*api)(void); /**< Storage API implementation */
void *(*opts_create)(const char *, size_t); /**< Storage options factory */
};
......@@ -53,11 +54,11 @@ struct engine {
struct network net;
module_array_t modules;
storage_registry_t storage_registry;
mm_ctx_t *pool;
knot_mm_t *pool;
struct lua_State *L;
};
int engine_init(struct engine *engine, mm_ctx_t *pool);
int engine_init(struct engine *engine, knot_mm_t *pool);
void engine_deinit(struct engine *engine);
/** @warning This function leaves 1 string result on stack. */
int engine_cmd(struct engine *engine, const char *str);
......
......@@ -118,9 +118,6 @@ struct sockaddr {
/* libknot */
typedef int knot_section_t; /* Do not touch */
typedef void knot_rrinfo_t; /* Do not touch */
typedef struct node {
struct node *next, *prev;
} node_t;
typedef uint8_t knot_dname_t;
typedef uint8_t knot_rdata_t;
typedef struct knot_rdataset {
......@@ -174,7 +171,6 @@ typedef struct {
size_t cap;
} rr_array_t;
struct kr_query {
node_t _node;
struct kr_query *parent;
knot_dname_t *sname;
uint16_t type;
......@@ -353,10 +349,6 @@ local kr_query_t = ffi.typeof('struct kr_query')
ffi.metatype( kr_query_t, {
__index = {
name = function(qry, new_name) return ffi.string(qry.sname, knot.knot_dname_size(qry.sname)) end,
next = function(qry)
assert(qry)
return C.kr_rplan_next(qry)
end,
resolved = function(qry)
return band(qry.flags, kres.query.RESOLVED) ~= 0
end,
......
......@@ -18,9 +18,11 @@
#include <string.h>
#include <getopt.h>
#include <uv.h>
#include <assert.h>
#include <contrib/cleanup.h>
#include <contrib/ucw/mempool.h>
#include <contrib/ccan/asprintf/asprintf.h>
#include <libknot/error.h>
#include "lib/defines.h"
#include "lib/resolve.h"
......@@ -141,7 +143,7 @@ static void help(int argc, char *argv[])
" [rundir] Path to the working directory (default: .)\n");
}
static struct worker_ctx *init_worker(uv_loop_t *loop, struct engine *engine, mm_ctx_t *pool, int worker_id, int worker_count)
static struct worker_ctx *init_worker(uv_loop_t *loop, struct engine *engine, knot_mm_t *pool, int worker_id, int worker_count)
{
/* Load bindings */
engine_lualib(engine, "modules", lib_modules);
......@@ -333,9 +335,9 @@ int main(int argc, char **argv)
uv_signal_start(&sigint, signal_handler, SIGINT);
uv_signal_start(&sigterm, signal_handler, SIGTERM);
/* Create a server engine. */
mm_ctx_t pool = {
knot_mm_t pool = {
.ctx = mp_new (4096),
.alloc = (mm_alloc_t) mp_alloc
.alloc = (knot_mm_alloc_t) mp_alloc
};
struct engine engine;
ret = engine_init(&engine, &pool);
......
......@@ -14,6 +14,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
#include "daemon/network.h"
#include "daemon/worker.h"
#include "daemon/io.h"
......
......@@ -20,10 +20,12 @@
#include <libknot/descriptor.h>
#include <contrib/ucw/lib.h>
#include <contrib/ucw/mempool.h>
#include <contrib/wire.h>
#if defined(__GLIBC__) && defined(_GNU_SOURCE)
#include <malloc.h>
#endif
#include <assert.h>
#include "lib/utils.h"
#include "daemon/worker.h"
#include "daemon/engine.h"
#include "daemon/io.h"
......@@ -227,9 +229,9 @@ static struct qr_task *qr_task_create(struct worker_ctx *worker, uv_handle_t *ha
}
/* Recycle available mempool if possible */
mm_ctx_t pool = {
knot_mm_t pool = {
.ctx = pool_take(worker),
.alloc = (mm_alloc_t) mp_alloc
.alloc = (knot_mm_alloc_t) mp_alloc
};
/* Create resolution task */
......@@ -265,7 +267,10 @@ static struct qr_task *qr_task_create(struct worker_ctx *worker, uv_handle_t *ha
task->on_complete = NULL;
/* Remember query source addr */
if (addr) {
memcpy(&task->source.addr, addr, sockaddr_len(addr));
size_t addr_len = sizeof(struct sockaddr_in);
if (addr->sa_family == AF_INET6)
addr_len = sizeof(struct sockaddr_in6);
memcpy(&task->source.addr, addr, addr_len);
task->req.qsource.addr = (const struct sockaddr *)&task->source.addr;
} else {
task->source.addr.ip4.sin_family = AF_UNSPEC;
......@@ -505,10 +510,10 @@ static void subreq_finalize(struct qr_task *task, const struct sockaddr *packet_
map_del(&task->worker->outstanding, key);
}
/* Notify waiting tasks. */
struct kr_query *leader_qry = TAIL(task->req.rplan.pending);
struct kr_query *leader_qry = array_tail(task->req.rplan.pending);
for (size_t i = task->waiting.len; i --> 0;) {
struct qr_task *follower = task->waiting.at[i];
struct kr_query *qry = TAIL(follower->req.rplan.pending);
struct kr_query *qry = array_tail(follower->req.rplan.pending);
/* Reuse MSGID and 0x20 secret */
if (qry) {
qry->id = leader_qry->id;
......@@ -773,7 +778,7 @@ int worker_reserve(struct worker_ctx *worker, size_t ring_maxlen)
return kr_error(ENOMEM);
memset(&worker->pkt_pool, 0, sizeof(worker->pkt_pool));
worker->pkt_pool.ctx = mp_new (4 * sizeof(knot_pkt_t));
worker->pkt_pool.alloc = (mm_alloc_t) mp_alloc;
worker->pkt_pool.alloc = (knot_mm_alloc_t) mp_alloc;
worker->outstanding = map_make();
return kr_ok();
}
......
......@@ -16,8 +16,6 @@
#pragma once
#include <libknot/internal/mempattern.h>
#include "daemon/engine.h"
#include "lib/generic/array.h"
#include "lib/generic/map.h"
......@@ -52,7 +50,7 @@ struct worker_ctx {
map_t outstanding;
mp_freelist_t pools;
mp_freelist_t ioreqs;
mm_ctx_t pkt_pool;
knot_mm_t pkt_pool;
};
/* Worker callback */
......
......@@ -259,10 +259,6 @@ In layers that either begin or finalize, you can walk the list of resolved queri
local last = req:resolved()
print(last.type)
last = last:next()
if last ~= nil then
print(last.type)
end
As described in the layers, you can not only retrieve information about current query, but also push new ones or pop old ones.
......
......@@ -20,8 +20,7 @@
#include <unistd.h>
#include <errno.h>
#include <libknot/internal/mempattern.h>
#include <libknot/internal/namedb/namedb_lmdb.h>
#include <libknot/db/db_lmdb.h>
#include <libknot/errcode.h>
#include <libknot/descriptor.h>
#include <libknot/dname.h>
......@@ -48,8 +47,8 @@ static void assert_right_version(struct kr_cache *cache)
if (ret != 0) {
return;