From: Niklas Hofmann Date: Fri, 8 Aug 2014 15:00:32 +0000 (+0200) Subject: allow multiple instances of avahi X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=97b93e51807c818c6ccd2e759e9cc380e0137b52;p=meshlink allow multiple instances of avahi --- diff --git a/avahi b/avahi index abf0d60e..7a5b2f69 160000 --- a/avahi +++ b/avahi @@ -1 +1 @@ -Subproject commit abf0d60e6dd933273887c1600e0793eac2706438 +Subproject commit 7a5b2f69af7d36d6cd4153142f125fa011784e03 diff --git a/examples/manynodes.c b/examples/manynodes.c index 991d5ba6..3df6cadb 100644 --- a/examples/manynodes.c +++ b/examples/manynodes.c @@ -8,7 +8,7 @@ #include "../src/meshlink.h" -static int n = 100; +static int n = 10; static meshlink_handle_t **mesh; static meshlink_node_t **nodes; diff --git a/src/meshlink.c b/src/meshlink.c index 601f49da..79db920b 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -48,7 +48,6 @@ typedef struct { #endif static pthread_mutex_t global_mutex; -static bool discovery_started; __thread meshlink_errno_t meshlink_errno; @@ -874,17 +873,7 @@ bool meshlink_start(meshlink_handle_t *mesh) { mesh->threadstarted=true; - // Start discovery - // Since only one Avahi instance can run in one program at the moment, make sure we only start one, ignore it otherwise. - - bool discovery_on = false; - pthread_mutex_lock(&global_mutex); - if(!discovery_started) - discovery_on = discovery_started = true; - pthread_mutex_unlock(&global_mutex); - - if(discovery_on) - discovery_start(mesh); + discovery_start(mesh); return true; } @@ -899,14 +888,7 @@ void meshlink_stop(meshlink_handle_t *mesh) { } // Stop discovery - - bool discovery_on = mesh->discovery_threadstarted; discovery_stop(mesh); - if(discovery_on) { - pthread_mutex_lock(&global_mutex); - discovery_started = false; - pthread_mutex_unlock(&global_mutex); - } // Shut down a listening socket to signal the main thread to shut down