X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fmeshlink.c;fp=src%2Fmeshlink.c;h=9a53d67aefae1c7e4e238fe9c784436c843bd58c;hb=ef2f0d4510168a77a6da16822b9401d1f14b69e0;hp=511a6d15546850ffe8b45d82b3c460bb75694cc2;hpb=62031be5f0a4b7e37a99cce43d0a77a67690e791;p=meshlink 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; }