Commit 62de8d42 authored by Marek Vavrusa's avatar Marek Vavrusa

Implemented new fdset API to TCP (now multithreaded!)

refs #1289
parent b55de02e
......@@ -608,7 +608,7 @@ int dt_start(dt_unit_t *unit)
int dt_start_id(dthread_t *thread)
{
// Check input
if (thread == 0) {
if (thread == 0 || thread->run == 0) {
return KNOTD_EINVAL;
}
......@@ -824,7 +824,7 @@ int dt_repurpose(dthread_t *thread, runnable_t runnable, void *data)
if (thread == 0) {
return KNOTD_EINVAL;
}
// Stop here if thread isn't a member of a unit
dt_unit_t *unit = thread->unit;
if (unit == 0) {
......
......@@ -314,9 +314,6 @@ static int server_bind_handlers(server_t *server)
tcp_unit_size = 3;
}
/*! \bug Bug prevents multithreading with libev-based TCP. */
tcp_unit_size = 1;
/* Lock config. */
conf_read_lock();
......@@ -344,9 +341,9 @@ static int server_bind_handlers(server_t *server)
/* Create TCP handlers. */
if (!iface->handler[TCP_ID]) {
unit = dt_create(tcp_unit_size); /*! \todo Multithreaded TCP. */
tcp_loop_unit(unit);
unit = dt_create(tcp_unit_size);
h = server_create_handler(server, iface->fd[TCP_ID], unit);
tcp_loop_unit(h, unit);
h->type = iface->type[TCP_ID];
h->iface = iface;
......@@ -430,7 +427,9 @@ iohandler_t *server_create_handler(server_t *server, int fd, dt_unit_t *unit)
// Update unit data object
for (int i = 0; i < unit->size; ++i) {
dthread_t *thread = unit->threads[i];
dt_repurpose(thread, thread->run, handler);
if (thread->run) {
dt_repurpose(thread, thread->run, handler);
}
}
/*! \todo This requires either RCU compatible ptr swap or locking. */
......
This diff is collapsed.
......@@ -26,9 +26,6 @@
#include "knot/server/server.h"
#include "knot/server/dthreads.h"
/*! \brief TCP event callback. */
typedef void (*tcp_cb_t)(struct ev_loop *, ev_io*, int);
/*!
* \brief Send TCP message.
*
......@@ -55,20 +52,6 @@ int tcp_send(int fd, uint8_t *msg, size_t msglen);
*/
int tcp_recv(int fd, uint8_t *buf, size_t len, sockaddr_t *addr);
/*!
* \brief Generic TCP event loop.
*
* Run TCP handler event loop.
*
* \param thread Associated thread from DThreads unit.
* \param fd First descriptor to be watched (or -1).
* \param cb Callback on fd event.
*
* \retval KNOTD_EOK on success.
* \retval KNOTD_EINVAL invalid parameters.
*/
int tcp_loop(dthread_t *thread, int fd, tcp_cb_t cb);
/*!
* \brief TCP event loop for accepting connections.
*
......@@ -94,12 +77,13 @@ int tcp_loop_worker(dthread_t *thread);
*
* Set-up threading unit for processing TCP requests.
*
* \param ioh Associated I/O handler.
* \param thread Associated thread from DThreads unit.
*
* \retval KNOTD_EOK on success.
* \retval KNOTD_EINVAL invalid parameters.
*/
int tcp_loop_unit(dt_unit_t *unit);
int tcp_loop_unit(iohandler_t *ioh, dt_unit_t *unit);
#endif // _KNOTD_TCPHANDLER_H_
......
......@@ -178,6 +178,9 @@ static inline void xfr_client_ev(struct ev_loop *loop, ev_io *w, int revents)
/*! \todo Log error. */
debug_xfr("xfr_client_ev: closing socket %d\n",
((ev_io *)w)->fd);
log_server_error("%cxfr_in: Failed to process response - %s\n",
request->type == XFR_TYPE_AIN ? 'a' : 'i',
knotd_strerror(ret));
ev_io_stop(loop, (ev_io *)w);
close(((ev_io *)w)->fd);
free(xfr_w);
......
......@@ -1128,7 +1128,7 @@ static int zones_insert_zones(knot_nameserver_t *ns,
((server_t *)knot_ns_get_data(ns))->sched);
}
knot_zone_contents_dump(knot_zone_get_contents(zone), 1);
// knot_zone_contents_dump(knot_zone_get_contents(zone), 1);
/* Directly discard zone. */
knot_dname_free(&zone_name);
......
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