X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-daemon%2Fstatic-services.c;h=659d00731f532e9ad99fdfc37d26b9e35e2a3ae3;hb=e63a65b3955b173a3e8d6b78c6377a518a9922d6;hp=0ac63263e8610ec1d0eca21c7532d2265f712cd3;hpb=66142b071a2497d7e3cf58d7bf5159bb1c970d84;p=catta diff --git a/avahi-daemon/static-services.c b/avahi-daemon/static-services.c index 0ac6326..659d007 100644 --- a/avahi-daemon/static-services.c +++ b/avahi-daemon/static-services.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include "main.h" @@ -152,7 +152,8 @@ static void static_service_free(StaticService *s) { static void static_service_group_free(StaticServiceGroup *g) { g_assert(g); - remove_static_service_group_from_server(g); + if (g->entry_group) + avahi_entry_group_free(g->entry_group); while (g->services) static_service_free(g->services); @@ -192,9 +193,6 @@ static void add_static_service_group_to_server(StaticServiceGroup *g) { g_assert(g); - if (g->entry_group) - return; - if (g->chosen_name) g_free(g->chosen_name); @@ -202,8 +200,11 @@ static void add_static_service_group_to_server(StaticServiceGroup *g) { g->chosen_name = replacestr(g->name, "%h", avahi_server_get_host_name(avahi_server)); else g->chosen_name = g_strdup(g->name); - - g->entry_group = avahi_entry_group_new(avahi_server, entry_group_callback, g); + + if (!g->entry_group) + g->entry_group = avahi_entry_group_new(avahi_server, entry_group_callback, g); + + g_assert(avahi_entry_group_is_empty(g->entry_group)); for (s = g->services; s; s = s->services_next) { @@ -213,8 +214,10 @@ static void add_static_service_group_to_server(StaticServiceGroup *g) { -1, AF_UNSPEC, g->chosen_name, s->type, s->domain_name, s->host_name, s->port, - avahi_string_list_copy(s->txt_records)) < 0) { - avahi_log_error("Failed to add service '%s' of type '%s', ignoring service group (%s)", g->chosen_name, s->type, g->filename); + s->txt_records) < 0) { + avahi_log_error("Failed to add service '%s' of type '%s', ignoring service group (%s): %s", + g->chosen_name, s->type, g->filename, + avahi_strerror(avahi_server_errno(avahi_server))); remove_static_service_group_from_server(g); return; } @@ -226,10 +229,8 @@ static void add_static_service_group_to_server(StaticServiceGroup *g) { static void remove_static_service_group_from_server(StaticServiceGroup *g) { g_assert(g); - if (g->entry_group) { - avahi_entry_group_free(g->entry_group); - g->entry_group = NULL; - } + if (g->entry_group) + avahi_entry_group_reset(g->entry_group); } typedef enum {