]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.c
Remove global variable "now".
[meshlink] / src / meshlink.c
index 4abacb1433afd18b35c2027d7aef64af1ad932a6..e6f44c0ce69a513f88c5736342dc33da2e83671d 100644 (file)
@@ -43,6 +43,7 @@ const char *meshlink_strerror(meshlink_errno_t errno) {
 // TODO: hack, remove once all global variables are gone.
 static void set_mesh(meshlink_handle_t *localmesh) {
        mesh = localmesh;
+       loop = &mesh->loop;
 }
 
 static bool ecdsa_keygen(meshlink_handle_t *mesh) {
@@ -212,6 +213,7 @@ meshlink_handle_t *meshlink_open(const char *confbase, const char *name) {
        meshlink_handle_t *mesh = xzalloc(sizeof *mesh);
        mesh->confbase = xstrdup(confbase);
        mesh->name = xstrdup(name);
+       event_loop_init(&mesh->loop);
        set_mesh(mesh);
 
        // TODO: should be set by a function.
@@ -288,7 +290,7 @@ void meshlink_close(meshlink_handle_t *mesh) {
        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) {
@@ -363,8 +365,6 @@ void meshlink_blacklist(meshlink_handle_t *mesh, meshlink_node_t *node) {
 }
 
 static void __attribute__((constructor)) meshlink_init(void) {
-       gettimeofday(&now, NULL);
-       srand(now.tv_sec + now.tv_usec);
        crypto_init();
 }