From: Saverio Proto Date: Tue, 3 Jun 2014 14:42:58 +0000 (+0200) Subject: only allow meshlink_join() when the library thread is not running X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=ef2f0d4510168a77a6da16822b9401d1f14b69e0;p=meshlink only allow meshlink_join() when the library thread is not running --- diff --git a/src/meshlink.c b/src/meshlink.c index 511a6d15..9a53d67a 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -1171,6 +1171,12 @@ 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"); + goto invalid; + } + // Connect to the meshlink daemon mentioned in the URL. struct addrinfo *ai = str2addrinfo(address, port, SOCK_STREAM); if(!ai) @@ -1261,7 +1267,7 @@ bool meshlink_join(meshlink_handle_t *mesh, const char *invitation) { return true; invalid: - fprintf(stderr, "Invalid invitation URL.\n"); + fprintf(stderr, "Invalid invitation URL or you are already connected to a Mesh ?\n"); return false; }