From 96c58e8ba51d67d1d90660ba8ff4f597c03688fe Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 3 May 2005 23:23:51 +0000 Subject: [PATCH] * decrease verbosity of debug messages * fix probe tie break * fix lexicographical compare function for records git-svn-id: file:///home/lennart/svn/public/avahi/trunk@38 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- announce.c | 20 ++++++++++---------- psched.c | 6 +++--- rr.c | 14 +++++++++++--- server.c | 16 ++++++++-------- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/announce.c b/announce.c index 613d10d..4be60b8 100644 --- a/announce.c +++ b/announce.c @@ -82,7 +82,7 @@ void flx_entry_group_check_probed(flxEntryGroup *g, gboolean immediately) { static void next_state(flxAnnouncement *a) { g_assert(a); - g_message("%i -- %u", a->state, a->n_iteration); +/* g_message("%i -- %u", a->state, a->n_iteration); */ if (a->state == FLX_WAITING) { @@ -305,13 +305,13 @@ gboolean flx_entry_registering(flxServer *s, flxEntry *e, flxInterface *i) { } static flxRecord *make_goodbye_record(flxRecord *r) { - gchar *t; +/* gchar *t; */ flxRecord *g; g_assert(r); - g_message("Preparing goodbye for record [%s]", t = flx_record_to_string(r)); - g_free(t); +/* g_message("Preparing goodbye for record [%s]", t = flx_record_to_string(r)); */ +/* g_free(t); */ g = flx_record_copy(r); g_assert(g->ref == 1); @@ -347,7 +347,7 @@ void flx_goodbye_interface(flxServer *s, flxInterface *i, gboolean goodbye) { g_assert(s); g_assert(i); - g_message("goodbye interface: %s.%u", i->hardware->name, i->protocol); +/* g_message("goodbye interface: %s.%u", i->hardware->name, i->protocol); */ if (goodbye && flx_interface_relevant(i)) { flxEntry *e; @@ -360,7 +360,7 @@ void flx_goodbye_interface(flxServer *s, flxInterface *i, gboolean goodbye) { while (i->announcements) remove_announcement(s, i->announcements); - g_message("goodbye interface done: %s.%u", i->hardware->name, i->protocol); +/* g_message("goodbye interface done: %s.%u", i->hardware->name, i->protocol); */ } @@ -368,7 +368,7 @@ void flx_goodbye_entry(flxServer *s, flxEntry *e, gboolean goodbye) { g_assert(s); g_assert(e); - g_message("goodbye entry: %p", e); +/* g_message("goodbye entry: %p", e); */ if (goodbye && !e->dead) flx_interface_monitor_walk(s->monitor, 0, AF_UNSPEC, send_goodbye_callback, e); @@ -376,7 +376,7 @@ void flx_goodbye_entry(flxServer *s, flxEntry *e, gboolean goodbye) { while (e->announcements) remove_announcement(s, e->announcements); - g_message("goodbye entry done: %p", e); +/* g_message("goodbye entry done: %p", e); */ } @@ -385,13 +385,13 @@ void flx_goodbye_all(flxServer *s, gboolean goodbye) { g_assert(s); - g_message("goodbye all"); +/* g_message("goodbye all"); */ for (e = s->entries; e; e = e->entries_next) if (!e->dead) flx_goodbye_entry(s, e, goodbye); - g_message("goodbye all done"); +/* g_message("goodbye all done"); */ } diff --git a/psched.c b/psched.c index 6f148ca..1c43164 100644 --- a/psched.c +++ b/psched.c @@ -8,7 +8,7 @@ #define FLX_RESPONSE_HISTORY_MSEC 700 #define FLX_RESPONSE_DEFER_MSEC 20 #define FLX_RESPONSE_JITTER_MSEC 100 -#define FLX_PROBE_DEFER_MSEC 20 +#define FLX_PROBE_DEFER_MSEC 70 flxPacketScheduler *flx_packet_scheduler_new(flxServer *server, flxInterface *i) { flxPacketScheduler *s; @@ -400,8 +400,8 @@ void flx_packet_scheduler_post_response(flxPacketScheduler *s, const flxAddress response_job_free(s, rj); } - g_message("ACCEPTED NEW RESPONSE [%s]", t = flx_record_to_string(record)); - g_free(t); +/* g_message("ACCEPTED NEW RESPONSE [%s]", t = flx_record_to_string(record)); */ +/* g_free(t); */ /* Create a new job and schedule it */ rj = response_job_new(s, record); diff --git a/rr.c b/rr.c index a71e2a0..db81658 100644 --- a/rr.c +++ b/rr.c @@ -456,6 +456,14 @@ gint flx_record_lexicographical_compare(flxRecord *a, flxRecord *b) { g_assert(a); g_assert(b); +/* gchar *t; */ + +/* g_message("comparing [%s]", t = flx_record_to_string(a)); */ +/* g_free(t); */ + +/* g_message("and [%s]", t = flx_record_to_string(b)); */ +/* g_free(t); */ + if (a->key->class < b->key->class) return -1; else if (a->key->class > b->key->class) @@ -474,9 +482,9 @@ gint flx_record_lexicographical_compare(flxRecord *a, flxRecord *b) { case FLX_DNS_TYPE_SRV: { gint r; - if ((r = uint16_cmp(a->data.srv.priority, b->data.srv.priority)) != 0 || - (r = uint16_cmp(a->data.srv.weight, b->data.srv.weight)) != 0 || - (r = uint16_cmp(a->data.srv.port, b->data.srv.port)) != 0) + if ((r = uint16_cmp(a->data.srv.priority, b->data.srv.priority)) == 0 && + (r = uint16_cmp(a->data.srv.weight, b->data.srv.weight)) == 0 && + (r = uint16_cmp(a->data.srv.port, b->data.srv.port)) == 0) r = lexicographical_domain_cmp(a->data.srv.name, b->data.srv.name); return r; diff --git a/server.c b/server.c index f43f414..a7c4f15 100644 --- a/server.c +++ b/server.c @@ -128,7 +128,6 @@ static void withdraw_entry(flxServer *s, flxEntry *e) { } s->need_entry_cleanup = TRUE; - } static void incoming_probe(flxServer *s, flxRecord *record, flxInterface *i) { @@ -141,23 +140,24 @@ static void incoming_probe(flxServer *s, flxRecord *record, flxInterface *i) { t = flx_record_to_string(record); - g_message("PROBE! PROBE! PROBE! [%s]", t); - +/* g_message("PROBE: [%s]", t); */ + for (e = g_hash_table_lookup(s->entries_by_key, record->key); e; e = n) { n = e->by_key_next; - - if (e->dead || !flx_record_equal_no_ttl(record, e->record)) + + if (e->dead || flx_record_equal_no_ttl(record, e->record)) continue; if (flx_entry_registering(s, e, i)) { gint cmp; - + if ((cmp = flx_record_lexicographical_compare(record, e->record)) > 0) { withdraw_entry(s, e); g_message("Recieved conflicting probe [%s]. Local host lost. Withdrawing.", t); } else if (cmp < 0) g_message("Recieved conflicting probe [%s]. Local host won.", t); + } } @@ -227,7 +227,7 @@ static gboolean handle_conflict(flxServer *s, flxInterface *i, flxRecord *record t = flx_record_to_string(record); - g_message("CHECKING FOR CONFLICT: [%s]", t); +/* g_message("CHECKING FOR CONFLICT: [%s]", t); */ for (e = g_hash_table_lookup(s->entries_by_key, record->key); e; e = n) { n = e->by_key_next; @@ -451,7 +451,7 @@ static void add_default_entries(flxServer *s) { uname(&utsname); r->data.hinfo.cpu = g_strdup(g_strup(utsname.machine)); r->data.hinfo.os = g_strdup(g_strup(utsname.sysname)); - flx_server_add(s, NULL, 0, AF_UNSPEC, FLX_ENTRY_UNIQUE | FLX_ENTRY_NOANNOUNCE | FLX_ENTRY_NOPROBE, r); + flx_server_add(s, NULL, 0, AF_UNSPEC, FLX_ENTRY_UNIQUE, r); flx_record_unref(r); /* Add localhost entries */ -- 2.39.5