X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-core%2Fserver.c;h=e565298d743aa76f927e84c62768a3127a88cd2d;hb=fd84f9ae1c1ccaf7090e0b4f8876948bea040117;hp=9356fec428851fabd9801c591f4728cc9229876e;hpb=3184280a20d54b8f468d0b8d6ff0980b74610ec5;p=catta diff --git a/avahi-core/server.c b/avahi-core/server.c index 9356fec..e565298 100644 --- a/avahi-core/server.c +++ b/avahi-core/server.c @@ -36,7 +36,7 @@ #include "socket.h" #include "browse.h" -#define AVAHI_HOST_RR_HOLDOFF_MSEC 1000 +#define AVAHI_HOST_RR_HOLDOFF_MSEC 2000 static void free_entry(AvahiServer*s, AvahiEntry *e) { AvahiEntry *t; @@ -226,16 +226,21 @@ static void incoming_probe(AvahiServer *s, AvahiRecord *record, AvahiInterface * gint cmp; n = e->by_key_next; - if (e->dead || !avahi_entry_probing(s, e, i)) + if (e->dead) continue; if ((cmp = avahi_record_lexicographical_compare(e->record, record)) == 0) { ours = TRUE; break; - } else if (cmp > 0) - won = TRUE; - else /* cmp < 0 */ - lost = TRUE; + } else { + + if (avahi_entry_probing(s, e, i)) { + if (cmp > 0) + won = TRUE; + else /* cmp < 0 */ + lost = TRUE; + } + } } t = avahi_record_to_string(record); @@ -243,9 +248,9 @@ static void incoming_probe(AvahiServer *s, AvahiRecord *record, AvahiInterface * if (!ours) { if (won) - g_message("Recieved conflicting probe [%s]. Local host won.", t); + g_message("xxx Recieved conflicting probe [%s]. Local host won.", t); else if (lost) { - g_message("Recieved conflicting probe [%s]. Local host lost. Withdrawing.", t); + g_message("yyy Recieved conflicting probe [%s]. Local host lost. Withdrawing.", t); withdraw_rrset(s, record->key); } } @@ -272,36 +277,36 @@ static gboolean handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord * /* Either our entry or the other is intended to be unique, so let's check */ - if (avahi_entry_registered(s, e, i)) { - - if (avahi_record_equal_no_ttl(e->record, record)) { - ours = TRUE; /* We have an identical record, so this is no conflict */ + if (avahi_record_equal_no_ttl(e->record, record)) { + ours = TRUE; /* We have an identical record, so this is no conflict */ + + /* Check wheter there is a TTL conflict */ + if (record->ttl <= e->record->ttl/2 && + avahi_entry_registered(s, e, i)) { + gchar *t; + /* Refresh */ + t = avahi_record_to_string(record); - /* 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_server_prepare_matching_responses(s, i, e->record->key, FALSE); - valid = FALSE; - - g_free(t); - } + g_message("Recieved record with bad TTL [%s]. Refreshing.", t); + 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 */ + break; + + } else { + + if (avahi_entry_registered(s, e, i)) { - /* There's no need to check the other entries of this RRset */ - break; - } else { /* A conflict => we have to return to probe mode */ conflict = TRUE; conflicting_entry = e; - } - } else if (avahi_entry_probing(s, e, i)) { + } else if (avahi_entry_probing(s, e, i)) { - if (!avahi_record_equal_no_ttl(record, e->record)) { - /* We are currently registering a matching record, but * someone else already claimed it, so let's * withdraw */