#endif
static pthread_mutex_t global_mutex;
-static bool discovery_started;
__thread meshlink_errno_t meshlink_errno;
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;
}
}
// 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