From: Saverio Proto Date: Wed, 4 Jun 2014 14:55:55 +0000 (+0200) Subject: Dont use pthread_kill X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=ae011af4d6186f2ff5582e2a6c48406be89da164;p=meshlink Dont use pthread_kill --- diff --git a/src/meshlink.c b/src/meshlink.c index 9a53d67a..50a5a483 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -736,6 +736,7 @@ meshlink_handle_t *meshlink_open(const char *confbase, const char *name) { mesh->name = xstrdup(name); pthread_mutex_init ( &(mesh->outpacketqueue_mutex), NULL); pthread_mutex_init ( &(mesh->nodes_mutex), NULL); + mesh->threadstarted = false; event_loop_init(&mesh->loop); mesh->loop.data = mesh; @@ -799,6 +800,8 @@ bool meshlink_start(meshlink_handle_t *mesh) { return false; } + mesh->threadstarted=true; + return true; } @@ -1172,8 +1175,7 @@ bool meshlink_join(meshlink_handle_t *mesh, const char *invitation) { char *b64key = ecdsa_get_base64_public_key(key); //Before doing meshlink_join make sure we are not connected to another mesh - if ( pthread_kill(mesh->thread,0) == 0){ - printf("HELLO\n"); + if ( mesh->threadstarted ){ goto invalid; } diff --git a/src/meshlink_internal.h b/src/meshlink_internal.h index cb60416d..72cf638e 100644 --- a/src/meshlink_internal.h +++ b/src/meshlink_internal.h @@ -60,6 +60,7 @@ struct meshlink_handle { meshlink_log_level_t log_level; pthread_t thread; + bool threadstarted; pthread_mutex_t outpacketqueue_mutex; pthread_mutex_t nodes_mutex; event_loop_t loop;