Commit 71189601 authored by Marek Vavruša's avatar Marek Vavruša

daemon: signal handlers, cleanup

parent 17dc0e94
......@@ -2,6 +2,12 @@
#include "lib/resolve.h"
#include "worker.h"
void signal_handler(uv_signal_t *handle, int signum)
{
uv_stop(uv_default_loop());
uv_signal_stop(handle);
}
int main(void)
{
mm_ctx_t mm;
......@@ -9,6 +15,11 @@ int main(void)
uv_loop_t *loop = uv_default_loop();
/* Block signals. */
uv_signal_t sigint;
uv_signal_init(loop, &sigint);
uv_signal_start(&sigint, signal_handler, SIGINT);
/* Bind to sockets. */
/* TODO: list of sockets, configurable loops. */
uv_udp_t udp_sock;
......
......@@ -2,17 +2,27 @@
#include "lib/defines.h"
#include <common/mempool.h>
static void delegpt_free(struct kr_ns *dp, mm_ctx_t *mm)
static void ns_free(struct kr_ns *ns, mm_ctx_t *mm)
{
mm_free(mm, dp->name);
mm_free(mm, dp);
mm_free(mm, ns->name);
mm_free(mm, ns);
}
static void nslist_free(list_t *list, mm_ctx_t *mm)
{
struct kr_ns *ns = NULL, *next = NULL;
WALK_LIST_DELSAFE(ns, next, *list) {
ns_free(ns, mm);
}
mm_free(mm, list);
}
static void delegmap_clear(struct kr_delegmap *map)
{
hattrie_iter_t *i = hattrie_iter_begin(map->trie, false);
while(!hattrie_iter_finished(i)) {
delegpt_free(*hattrie_iter_val(i), map->pool);
list_t *nslist = *hattrie_iter_val(i);
nslist_free(nslist, map->pool);
hattrie_iter_next(i);
}
hattrie_iter_free(i);
......@@ -124,5 +134,5 @@ void kr_ns_invalidate(struct kr_ns *ns)
void kr_ns_remove(struct kr_ns *ns, mm_ctx_t *mm)
{
rem_node((node_t *)ns);
delegpt_free(ns, mm);
ns_free(ns, mm);
}
\ No newline at end of file
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