X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-core%2Fserver.c;h=dd0f707b6be3a957fc320cd4362358bf54d2a273;hb=22a61b042376903deada022e7585e0585aaa7d43;hp=4085276598f03458d0fe93828b4e9f413d7acaf5;hpb=26358a4c4a8ae0ca68f08054e367aa3687681445;p=catta diff --git a/avahi-core/server.c b/avahi-core/server.c index 4085276..dd0f707 100644 --- a/avahi-core/server.c +++ b/avahi-core/server.c @@ -33,7 +33,7 @@ #include "util.h" #include "iface.h" #include "socket.h" -#include "subscribe.h" +#include "resolve.h" #define AVAHI_HOST_RR_HOLDOFF_MSEC 1000 @@ -102,6 +102,9 @@ static void cleanup_dead(AvahiServer *s) { s->need_entry_cleanup = FALSE; } + + if (s->need_browser_cleanup) + avahi_browser_cleanup(s); } static void enum_aux_records(AvahiServer *s, AvahiInterface *i, const gchar *name, guint16 type, void (*callback)(AvahiServer *s, AvahiRecord *r, gboolean flush_cache, gpointer userdata), gpointer userdata) { @@ -252,13 +255,11 @@ static void incoming_probe(AvahiServer *s, AvahiRecord *record, AvahiInterface * static gboolean handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *record, gboolean unique, const AvahiAddress *a) { gboolean valid = TRUE, ours = FALSE, conflict = FALSE, withdraw_immediately = FALSE; AvahiEntry *e, *n, *conflicting_entry = NULL; - gchar *t; g_assert(s); g_assert(i); g_assert(record); - t = avahi_record_to_string(record); /* g_message("CHECKING FOR CONFLICT: [%s]", t); */ @@ -277,10 +278,15 @@ static gboolean handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord * /* Check wheter there is a TTL conflict */ if (record->ttl <= e->record->ttl/2) { + gchar *t; /* Refresh */ + t = avahi_record_to_string(record); + g_message("Recieved record with bad TTL [%s]. Refreshing.", t); - avahi_interface_post_response(i, e->record, FALSE, NULL, TRUE); + avahi_server_prepare_matching_responses(s, i, e->record->key, FALSE); valid = FALSE; + + g_free(t); } /* There's no need to check the other entries of this RRset */ @@ -307,8 +313,12 @@ static gboolean handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord * /* g_message("ours=%i conflict=%i", ours, conflict); */ if (!ours && conflict) { + gchar *t; + valid = FALSE; + t = avahi_record_to_string(record); + if (withdraw_immediately) { g_message("Recieved conflicting record [%s] with local record to be. Withdrawing.", t); withdraw_rrset(s, record->key); @@ -320,9 +330,9 @@ static gboolean handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord * /* Local unique records are returned to probin * state. Local shared records are reannounced. */ } - } - g_free(t); + g_free(t); + } return valid; } @@ -900,7 +910,7 @@ AvahiServer *avahi_server_new(GMainContext *c, const AvahiServerConfig *sc, Avah s = g_new(AvahiServer, 1); s->n_host_rr_pending = 0; - s->need_entry_cleanup = s->need_group_cleanup = FALSE; + s->need_entry_cleanup = s->need_group_cleanup = s->need_browser_cleanup = FALSE; if (sc) avahi_server_config_copy(&s->config, sc); @@ -950,8 +960,11 @@ AvahiServer *avahi_server_new(GMainContext *c, const AvahiServerConfig *sc, Avah s->entries_by_key = g_hash_table_new((GHashFunc) avahi_key_hash, (GEqualFunc) avahi_key_equal); AVAHI_LLIST_HEAD_INIT(AvahiGroup, s->groups); - AVAHI_LLIST_HEAD_INIT(AvahiSubscription, s->subscriptions); - s->subscription_hashtable = g_hash_table_new((GHashFunc) avahi_key_hash, (GEqualFunc) avahi_key_equal); + AVAHI_LLIST_HEAD_INIT(AvahiRecordBrowser, s->record_browsers); + s->record_browser_hashtable = g_hash_table_new((GHashFunc) avahi_key_hash, (GEqualFunc) avahi_key_equal); + AVAHI_LLIST_HEAD_INIT(AvahiHostNameResolver, s->host_name_resolvers); + AVAHI_LLIST_HEAD_INIT(AvahiAddressResolver, s->address_resolvers); + AVAHI_LLIST_HEAD_INIT(AvahiDomainBrowser, s->domain_browsers); /* Get host name */ s->host_name = s->config.host_name ? avahi_normalize_name(s->config.host_name) : avahi_get_host_name(); @@ -990,9 +1003,15 @@ void avahi_server_free(AvahiServer* s) { while (s->groups) free_group(s, s->groups); - while (s->subscriptions) - avahi_subscription_free(s->subscriptions); - g_hash_table_destroy(s->subscription_hashtable); + while (s->host_name_resolvers) + avahi_host_name_resolver_free(s->host_name_resolvers); + while (s->address_resolvers) + avahi_address_resolver_free(s->address_resolvers); + while (s->domain_browsers) + avahi_domain_browser_free(s->domain_browsers); + while (s->record_browsers) + avahi_record_browser_destroy(s->record_browsers); + g_hash_table_destroy(s->record_browser_hashtable); g_hash_table_destroy(s->entries_by_key); @@ -1464,7 +1483,7 @@ void avahi_server_set_data(AvahiServer *s, gpointer userdata) { s->userdata = userdata; } -AvahiServerState avhai_server_get_state(AvahiServer *s) { +AvahiServerState avahi_server_get_state(AvahiServer *s) { g_assert(s); return s->state;