From 48cfb3c876636d79dace3ebc8e82c946bc0b7ebf Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 30 Jul 2005 01:13:56 +0000 Subject: * add new tool avahi-publish-address * avahi-publish-service: fail after 12 collisions * avahi-daemon: dump record data on SIGUSR1 to syslog * avahi-core: * improve dumping API * shorten response history time to 500ms, infriniging the RFC but fixing ping-pong behaviour on RR registration * remove gcc warning git-svn-id: file:///home/lennart/svn/public/avahi/trunk@195 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-core/server.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'avahi-core/server.c') diff --git a/avahi-core/server.c b/avahi-core/server.c index b3ab009..d63f5ec 100644 --- a/avahi-core/server.c +++ b/avahi-core/server.c @@ -223,6 +223,10 @@ static void incoming_probe(AvahiServer *s, AvahiRecord *record, AvahiInterface * g_assert(record); g_assert(i); + t = avahi_record_to_string(record); + +/* avahi_log_debug("incoming_probe()"); */ + for (e = g_hash_table_lookup(s->entries_by_key, record->key); e; e = n) { gint cmp; n = e->by_key_next; @@ -244,8 +248,6 @@ static void incoming_probe(AvahiServer *s, AvahiRecord *record, AvahiInterface * } } - t = avahi_record_to_string(record); - if (!ours) { if (won) @@ -253,7 +255,8 @@ static void incoming_probe(AvahiServer *s, AvahiRecord *record, AvahiInterface * else if (lost) { avahi_log_debug("Recieved conflicting probe [%s]. Local host lost. Withdrawing.", t); withdraw_rrset(s, record->key); - } + }/* else */ +/* avahi_log_debug("Not conflicting probe"); */ } g_free(t); @@ -334,7 +337,7 @@ static gboolean handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord * avahi_log_debug("Recieved conflicting record [%s]. Resetting our record.", t); avahi_entry_return_to_initial_state(s, conflicting_entry, i); - /* Local unique records are returned to probin + /* Local unique records are returned to probing * state. Local shared records are reannounced. */ } @@ -1527,25 +1530,29 @@ const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiEntryGroup *g, void return avahi_record_ref((*e)->record); } -void avahi_server_dump(AvahiServer *s, FILE *f) { +void avahi_server_dump(AvahiServer *s, AvahiDumpCallback callback, gpointer userdata) { AvahiEntry *e; + g_assert(s); - g_assert(f); + g_assert(callback); - fprintf(f, "\n;;; ZONE DUMP FOLLOWS ;;;\n"); + callback(";;; ZONE DUMP FOLLOWS ;;;", userdata); for (e = s->entries; e; e = e->entries_next) { gchar *t; + gchar ln[256]; if (e->dead) continue; t = avahi_record_to_string(e->record); - fprintf(f, "%s ; iface=%i proto=%i\n", t, e->interface, e->protocol); + snprintf(ln, sizeof(ln), "%s ; iface=%i proto=%i", t, e->interface, e->protocol); g_free(t); + + callback(ln, userdata); } - avahi_dump_caches(s->monitor, f); + avahi_dump_caches(s->monitor, callback, userdata); } gint avahi_server_add_ptr( -- cgit