Commit 3c48c1ee authored by Marek Vavrusa's avatar Marek Vavrusa

Updated net IO handler.

parent 4c8ab94d
......@@ -146,11 +146,8 @@ static int tcp_handle(ns_proc_context_t *query_ctx, int fd,
rx->iov_len = ret;
}
/* Reset context. */
uint16_t tx_len = tx->iov_len;
ns_proc_reset(query_ctx);
/* Input packet. */
uint16_t tx_len = tx->iov_len;
int state = ns_proc_in(rx->iov_base, rx->iov_len, query_ctx);
/* Resolve until NOOP or finished. */
......@@ -167,6 +164,9 @@ static int tcp_handle(ns_proc_context_t *query_ctx, int fd,
}
}
/* Reset after processing. */
ns_proc_reset(query_ctx);
return ret;
}
......@@ -467,12 +467,16 @@ int tcp_loop_worker(dthread_t *thread)
int ret = KNOT_EOK;
ns_proc_context_t query_ctx;
memset(&query_ctx, 0, sizeof(query_ctx));
mm_ctx_init(&query_ctx.mm);
query_ctx.ns = w->ioh->server->nameserver;
mm_ctx_mempool(&query_ctx.mm, 2 * sizeof(knot_pkt_t));
/* Packet size not limited by EDNS. */
query_ctx.flags |= NS_PKTSIZE_NOLIMIT;
/* Create query processing context. */
ns_proc_begin(&query_ctx, NS_PROC_QUERY);
/* Create iovec abstraction. */
mm_ctx_t *mm = &query_ctx.mm;
struct iovec bufs[2];
......@@ -485,9 +489,6 @@ int tcp_loop_worker(dthread_t *thread)
}
}
/* Create query processing context. */
ns_proc_begin(&query_ctx, NS_PROC_QUERY);
/* Accept clients. */
dbg_net("tcp: worker %p started\n", w);
fdset_t *set = &w->set;
......@@ -562,7 +563,7 @@ int tcp_loop_worker(dthread_t *thread)
}
finish:
mp_delete(mm->ctx);
ns_proc_finish(&query_ctx);
return ret;
}
......
......@@ -143,11 +143,8 @@ int udp_handle(ns_proc_context_t *query_ctx, int fd, sockaddr_t *addr,
strfrom, sockaddr_portnum(addr));
#endif
/* Reset context. */
uint16_t tx_len = tx->iov_len;
ns_proc_reset(query_ctx);
/* Input packet. */
uint16_t tx_len = tx->iov_len;
int state = ns_proc_in(rx->iov_base, rx->iov_len, query_ctx);
/* Process answer. */
......@@ -167,6 +164,9 @@ int udp_handle(ns_proc_context_t *query_ctx, int fd, sockaddr_t *addr,
tx->iov_len = 0;
}
/* Reset context. */
ns_proc_reset(query_ctx);
return KNOT_EOK;
/*! \todo Move RRL to IN processing. */
......@@ -501,7 +501,7 @@ int udp_reader(iohandler_t *h, dthread_t *thread)
ns_proc_context_t query_ctx;
memset(&query_ctx, 0, sizeof(query_ctx));
query_ctx.ns = h->server->nameserver;
mm_ctx_mempool(&query_ctx.mm, 2 * sizeof(knot_pkt_t));
mm_ctx_mempool(&query_ctx.mm, sizeof(knot_pkt_t));
/* Disable transfers over UDP. */
query_ctx.flags |= NS_QUERY_NO_AXFR;
......@@ -562,6 +562,8 @@ int udp_reader(iohandler_t *h, dthread_t *thread)
if (FD_ISSET(fd, &rfds)) {
while ((rcvd = _udp_recv(fd, rq)) > 0) {
_udp_handle(&query_ctx, rq);
/* Flush allocated memory. */
mp_flush(query_ctx.mm.ctx);
_udp_send(rq);
udp_pps_sample(rcvd, thr_id);
}
......
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