#include <stdlib.h>
#include <string.h>
#include <getopt.h>
-
#include <uv.h>
-
#include <libknot/internal/sockaddr.h>
-#include <libknot/errcode.h>
#include "lib/defines.h"
#include "lib/resolve.h"
}
static void tty_alloc(uv_handle_t *handle, size_t suggested, uv_buf_t *buf) {
- buf->len = suggested;
- buf->base = malloc(suggested);
+ buf->len = suggested;
+ buf->base = malloc(suggested);
}
void signal_handler(uv_signal_t *handle, int signum)
{
uv_stop(uv_default_loop());
uv_signal_stop(handle);
- exit(1);
}
static void help(int argc, char *argv[])
static void buf_alloc(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf)
{
struct worker_ctx *worker = handle->data;
- buf->base = mm_alloc(worker->pool, suggested_size);
+ buf->base = mm_alloc(worker->mm, suggested_size);
buf->len = suggested_size;
}
static void buf_free(uv_handle_t* handle, const uv_buf_t* buf)
{
struct worker_ctx *worker = handle->data;
- mm_free(worker->pool, buf->base);
+ mm_free(worker->mm, buf->base);
}
static void tcp_send(uv_handle_t *handle, const knot_pkt_t *answer)
static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf)
{
struct worker_ctx *worker = handle->data;
- assert(worker->pool);
/* Check the incoming wire length (malformed, EOF or error). */
- if (nread < sizeof(uint16_t)) {
+ if (nread < (ssize_t) sizeof(uint16_t)) {
buf_free((uv_handle_t *)handle, buf);
tcp_unbind((uv_handle_t *)handle);
free(handle);
nread = wire_read_u16((const uint8_t *)buf->base);
/* Create packets */
- knot_pkt_t *query = knot_pkt_new(buf->base + sizeof(uint16_t), nread, worker->pool);
- knot_pkt_t *answer = knot_pkt_new(NULL, KNOT_WIRE_MAX_PKTSIZE, worker->pool);
+ knot_pkt_t *query = knot_pkt_new(buf->base + sizeof(uint16_t), nread, worker->mm);
+ knot_pkt_t *answer = knot_pkt_new(NULL, KNOT_WIRE_MAX_PKTSIZE, worker->mm);
/* Resolve */
int ret = worker_exec(worker, answer, query);
static void buf_alloc(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf)
{
struct worker_ctx *worker = handle->data;
- buf->base = mm_alloc(worker->pool, suggested_size);
+ buf->base = mm_alloc(worker->mm, suggested_size);
buf->len = suggested_size;
}
static void buf_free(uv_handle_t* handle, const uv_buf_t* buf)
{
struct worker_ctx *worker = handle->data;
- mm_free(worker->pool, buf->base);
+ mm_free(worker->mm, buf->base);
}
static void udp_send(uv_udp_t *handle, knot_pkt_t *answer, const struct sockaddr *addr)
const struct sockaddr *addr, unsigned flags)
{
struct worker_ctx *worker = handle->data;
- assert(worker->pool);
/* Check the incoming wire length. */
if (nread < KNOT_WIRE_HEADER_SIZE) {
}
/* Create packets */
- knot_pkt_t *query = knot_pkt_new(buf->base, nread, worker->pool);
- knot_pkt_t *answer = knot_pkt_new(NULL, KNOT_WIRE_MAX_PKTSIZE, worker->pool);
+ knot_pkt_t *query = knot_pkt_new(buf->base, nread, worker->mm);
+ knot_pkt_t *answer = knot_pkt_new(NULL, KNOT_WIRE_MAX_PKTSIZE, worker->mm);
/* Resolve */
int ret = worker_exec(worker, answer, query);
*/
struct worker_ctx {
struct kr_context resolve;
- mm_ctx_t *pool;
+ mm_ctx_t *mm;
};
/**