meshlink_handle_t *mesh = xzalloc(sizeof *mesh);
mesh->confbase = xstrdup(confbase);
mesh->name = xstrdup(name);
+ event_loop_init(&mesh->loop);
+ mesh->loop.data = mesh;
set_mesh(mesh);
// TODO: should be set by a function.
init_configuration(&mesh->config);
- if(!read_server_config())
+ if(!read_server_config(mesh))
return meshlink_close(mesh), NULL;
// Setup up everything
// TODO: we should not open listening sockets yet
- if(!setup_network())
+ if(!setup_network(mesh))
return meshlink_close(mesh), NULL;
return mesh;
void *meshlink_main_loop(void *arg) {
meshlink_handle_t *mesh = arg;
- try_outgoing_connections();
+ try_outgoing_connections(mesh);
main_loop();
logger(DEBUG_ALWAYS, LOG_NOTICE, "Terminating");
exit_configuration(&mesh->config);
-
+ event_loop_exit(&mesh->loop);
}
void meshlink_set_receive_cb(meshlink_handle_t *mesh, meshlink_receive_cb_t cb) {
}
static void __attribute__((constructor)) meshlink_init(void) {
- gettimeofday(&now, NULL);
- srand(now.tv_sec + now.tv_usec);
crypto_init();
}