Commit 157d3c64 authored by Marek Vavruša's avatar Marek Vavruša

daemon/engine: made ‘network’ manager part of the engine

parent c198a21f
......@@ -138,6 +138,8 @@ int engine_init(struct engine *engine, mm_ctx_t *pool)
if (ret != 0) {
return ret;
}
/* Initialize network */
network_init(&engine->net, uv_default_loop());
return ret;
}
......@@ -148,6 +150,8 @@ void engine_deinit(struct engine *engine)
return;
}
network_deinit(&engine->net);
/* Unload modules. */
for (size_t i = 0; i < engine->modules.len; ++i) {
kr_module_unload(&engine->modules.at[i]);
......
......@@ -22,11 +22,12 @@
struct lua_State;
#include "lib/resolve.h"
#include "lib/generic/array.h"
#include "daemon/network.h"
struct engine {
struct kr_context resolver;
modulelist_t modules;
struct network net;
mm_ctx_t *pool;
struct lua_State *L;
};
......
......@@ -146,9 +146,7 @@ int main(int argc, char **argv)
loop->data = &worker;
/* Bind to sockets. */
struct network net;
network_init(&net, loop);
ret = network_listen(&net, addr, (uint16_t)port, NET_UDP|NET_TCP);
ret = network_listen(&engine.net, addr, (uint16_t)port, NET_UDP|NET_TCP);
if (ret != 0) {
fprintf(stderr, "[system] bind to '%s#%d' %s\n", addr, port, knot_strerror(ret));
ret = EXIT_FAILURE;
......@@ -172,7 +170,6 @@ int main(int argc, char **argv)
/* Cleanup. */
fprintf(stderr, "\n[system] quitting\n");
network_deinit(&net);
engine_deinit(&engine);
return ret;
......
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