X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-daemon%2Fstatic-services.c;h=03824fde497b04511de758302a7ed47a3ee0bb07;hb=b789f76475170c84fce85383279aa8f683ad1ff9;hp=1f9b765099f0dd34501bc35e0d680e57b9d67940;hpb=f43187377e0c89ba02ca23e88efa01bbb255e037;p=catta diff --git a/avahi-daemon/static-services.c b/avahi-daemon/static-services.c index 1f9b765..03824fd 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" @@ -63,7 +63,7 @@ struct StaticServiceGroup { gchar *name, *chosen_name; gboolean replace_wildcards; - AvahiEntryGroup *entry_group; + AvahiSEntryGroup *entry_group; AVAHI_LLIST_HEAD(StaticService, services); AVAHI_LLIST_FIELDS(StaticServiceGroup, groups); }; @@ -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_s_entry_group_free(g->entry_group); while (g->services) static_service_free(g->services); @@ -165,7 +166,7 @@ static void static_service_group_free(StaticServiceGroup *g) { g_free(g); } -static void entry_group_callback(AvahiServer *s, AvahiEntryGroup *eg, AvahiEntryGroupState state, gpointer userdata) { +static void entry_group_callback(AvahiServer *s, AvahiSEntryGroup *eg, AvahiEntryGroupState state, gpointer userdata) { StaticServiceGroup *g = userdata; g_assert(s); @@ -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_s_entry_group_new(avahi_server, entry_group_callback, g); + + g_assert(avahi_s_entry_group_is_empty(g->entry_group)); for (s = g->services; s; s = s->services_next) { @@ -214,22 +215,22 @@ static void add_static_service_group_to_server(StaticServiceGroup *g) { g->chosen_name, s->type, s->domain_name, s->host_name, s->port, 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); + 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; } } - avahi_entry_group_commit(g->entry_group); + avahi_s_entry_group_commit(g->entry_group); } 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_s_entry_group_reset(g->entry_group); } typedef enum { @@ -348,7 +349,7 @@ static void XMLCALL xml_end(void *data, const char *el) { case XML_TAG_SERVICE: - if (u->service->port == 0 || !u->service->type) { + if (!u->service->type) { avahi_log_error("%s: parse failure: service incomplete.", u->group->filename); u->failed = TRUE; return; @@ -368,7 +369,7 @@ static void XMLCALL xml_end(void *data, const char *el) { p = u->buf ? atoi(u->buf) : 0; - if (p <= 0 || p > 0xFFFF) { + if (p < 0 || p > 0xFFFF) { avahi_log_error("%s: parse failure: invalid port specification \"%s\".", u->group->filename, u->buf); u->failed = TRUE; return;