X-Git-Url: http://git.meshlink.io/?p=meshlink;a=blobdiff_plain;f=src%2Fdiscovery.c;h=95e5ed65d86da5e75297fd0fa94a9dd8eb9e762f;hp=67a349499c9c4a0162a5252aa38797f0e4775602;hb=230b5907e242aa48bb8c8d09450fbd3767e9c24a;hpb=031ebcf6065bccc6279a6745676b0e4b9f7fda80 diff --git a/src/discovery.c b/src/discovery.c index 67a34949..95e5ed65 100644 --- a/src/discovery.c +++ b/src/discovery.c @@ -15,6 +15,7 @@ #include "logger.h" #include "node.h" #include "connection.h" +#include "xalloc.h" #define MESHLINK_MDNS_SERVICE_TYPE "_%s._tcp" #define MESHLINK_MDNS_NAME_KEY "name" @@ -60,7 +61,7 @@ static void discovery_entry_group_callback(CattaServer *server, CattaSEntryGroup case CATTA_ENTRY_GROUP_UNCOMMITED: case CATTA_ENTRY_GROUP_REGISTERING: - ; + break; } pthread_mutex_unlock(&(mesh->mesh_mutex)); @@ -310,9 +311,17 @@ static void discovery_browse_callback(CattaSServiceBrowser *browser, CattaIfInde case CATTA_BROWSER_NEW: catta_s_service_resolver_new(mesh->catta_server, interface_, protocol, name, type, domain, CATTA_PROTO_UNSPEC, 0, discovery_resolve_callback, mesh); + pthread_mutex_lock(&mesh->mesh_mutex); + handle_network_change(mesh, ++mesh->catta_interfaces); + pthread_mutex_unlock(&mesh->mesh_mutex); break; case CATTA_BROWSER_REMOVE: + pthread_mutex_lock(&mesh->mesh_mutex); + handle_network_change(mesh, --mesh->catta_interfaces); + pthread_mutex_unlock(&mesh->mesh_mutex); + break; + case CATTA_BROWSER_ALL_FOR_NOW: case CATTA_BROWSER_CACHE_EXHAUSTED: break; @@ -500,4 +509,6 @@ void discovery_stop(meshlink_handle_t *mesh) { free(mesh->catta_servicetype); mesh->catta_servicetype = NULL; } + + mesh->catta_interfaces = 0; }