]> git.meshlink.io Git - meshlink/commitdiff
Initialize mesh->self before network setup
authorSaverio Proto <zioproto@gmail.com>
Wed, 11 Jun 2014 19:12:40 +0000 (21:12 +0200)
committerSaverio Proto <zioproto@gmail.com>
Wed, 11 Jun 2014 19:12:40 +0000 (21:12 +0200)
src/meshlink.c
src/net_setup.c

index c703ddbe6da3bb205ecff27b67bde3fcbe3a62db..31f2410c2d7cbb5e000e68e50cfe131d50412edc 100644 (file)
@@ -737,6 +737,8 @@ meshlink_handle_t *meshlink_open(const char *confbase, const char *name) {
        meshlink_handle_t *mesh = xzalloc(sizeof *mesh);
        mesh->confbase = xstrdup(confbase);
        if (usingname) mesh->name = xstrdup(name);
+       mesh->self = new_node();
+       mesh->self->connection = new_connection();
        pthread_mutex_init ( &(mesh->outpacketqueue_mutex), NULL);
        pthread_mutex_init ( &(mesh->nodes_mutex), NULL);
        mesh->threadstarted = false;
index e8ed948772e4bf9ec546f8a3820b9e54b3133902..4ee4b95362a4a999a9e6b6715a78bb430a57d7fc 100644 (file)
@@ -273,8 +273,6 @@ bool setup_myself(meshlink_handle_t *mesh) {
                return false;
        }
 
-       mesh->self = new_node();
-       mesh->self->connection = new_connection();
        mesh->self->name = name;
        mesh->self->connection->name = xstrdup(name);
        read_host_config(mesh, mesh->config, name);