X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fconnection.c;h=adecae8b82746d116c99727bd2ab21def9cdac44;hb=fa05f996c5500c056a36c1d43e33a407f876643c;hp=05a9d653dc3bf377128b5eb73bd4017dfba2c2c5;hpb=a1b50920b9a52f86ca6e33fcb24d7fa34313a1ee;p=meshlink diff --git a/src/connection.c b/src/connection.c index 05a9d653..adecae8b 100644 --- a/src/connection.c +++ b/src/connection.c @@ -32,12 +32,17 @@ void init_connections(meshlink_handle_t *mesh) { mesh->connections = list_alloc((list_action_t) free_connection); mesh->everyone = new_connection(); mesh->everyone->name = xstrdup("mesh->everyone"); - mesh->everyone->hostname = xstrdup("BROADCAST"); } void exit_connections(meshlink_handle_t *mesh) { - list_delete_list(mesh->connections); + if(mesh->connections) { + list_delete_list(mesh->connections); + } + free_connection(mesh->everyone); + + mesh->connections = NULL; + mesh->everyone = NULL; } connection_t *new_connection(void) { @@ -45,8 +50,9 @@ connection_t *new_connection(void) { } void free_connection(connection_t *c) { - if(!c) + if(!c) { return; + } sptps_stop(&c->sptps); ecdsa_free(c->ecdsa); @@ -54,17 +60,15 @@ void free_connection(connection_t *c) { buffer_clear(&c->inbuf); buffer_clear(&c->outbuf); - if(c->io.cb) + if(c->io.cb) { abort(); + } - if(c->socket > 0) + if(c->socket > 0) { closesocket(c->socket); + } free(c->name); - free(c->hostname); - - if(c->config_tree) - exit_configuration(&c->config_tree); free(c); }