X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-core%2Fentry.c;h=55c9ea29d99804c3cdd972d0a4ce2206b1095950;hb=750305f2323c41b60ffa2d1333210d5114e556f8;hp=d2946474a3403c3906ab32ac62e1049f3b25d8cd;hpb=82244abd57cf04d554b3ab0fa92642d73d80b5c1;p=catta diff --git a/avahi-core/entry.c b/avahi-core/entry.c index d294647..55c9ea2 100644 --- a/avahi-core/entry.c +++ b/avahi-core/entry.c @@ -161,6 +161,11 @@ static int check_record_conflict(AvahiServer *s, AvahiIfIndex interface, AvahiPr if ((flags & AVAHI_PUBLISH_ALLOW_MULTIPLE) && (e->flags & AVAHI_PUBLISH_ALLOW_MULTIPLE) ) continue; + if (avahi_record_equal_no_ttl(r, e->record)) { + /* The records are the same, not a conflict in any case */ + continue; + } + if ((interface <= 0 || e->interface <= 0 || e->interface == interface) && @@ -216,7 +221,10 @@ static AvahiEntry * server_add_internal( transport_flags_from_domain(s, &flags, r->key->name); AVAHI_CHECK_VALIDITY_RETURN_NULL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED); AVAHI_CHECK_VALIDITY_RETURN_NULL(s, !s->config.disable_publishing, AVAHI_ERR_NOT_PERMITTED); - AVAHI_CHECK_VALIDITY_RETURN_NULL(s, !g || (g->state != AVAHI_ENTRY_GROUP_ESTABLISHED && g->state != AVAHI_ENTRY_GROUP_REGISTERING), AVAHI_ERR_BAD_STATE); + AVAHI_CHECK_VALIDITY_RETURN_NULL(s, + !g || + (g->state != AVAHI_ENTRY_GROUP_ESTABLISHED && g->state != AVAHI_ENTRY_GROUP_REGISTERING) || + (flags & AVAHI_PUBLISH_UPDATE), AVAHI_ERR_BAD_STATE); if (flags & AVAHI_PUBLISH_UPDATE) { AvahiRecord *old_record; @@ -443,7 +451,7 @@ int avahi_server_add_address( AVAHI_PUBLISH_UPDATE| AVAHI_PUBLISH_USE_WIDE_AREA| AVAHI_PUBLISH_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS); - AVAHI_CHECK_VALIDITY(s, !name || avahi_is_valid_domain_name(name), AVAHI_ERR_INVALID_HOST_NAME); + AVAHI_CHECK_VALIDITY(s, !name || avahi_is_valid_fqdn(name), AVAHI_ERR_INVALID_HOST_NAME); /* Prepare the host naem */ @@ -587,7 +595,7 @@ static int server_add_service_strlst_nocopy( AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_name(name), AVAHI_ERR_INVALID_SERVICE_NAME); AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_type_strict(type), AVAHI_ERR_INVALID_SERVICE_TYPE); AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME); - AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !host || avahi_is_valid_domain_name(host), AVAHI_ERR_INVALID_HOST_NAME); + AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !host || avahi_is_valid_fqdn(host), AVAHI_ERR_INVALID_HOST_NAME); if (!domain) domain = s->domain_name; @@ -901,7 +909,7 @@ static AvahiEntry *server_add_dns_server_name( AVAHI_CHECK_VALIDITY_RETURN_NULL(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_USE_WIDE_AREA|AVAHI_PUBLISH_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS); AVAHI_CHECK_VALIDITY_RETURN_NULL(s, type == AVAHI_DNS_SERVER_UPDATE || type == AVAHI_DNS_SERVER_RESOLVE, AVAHI_ERR_INVALID_FLAGS); AVAHI_CHECK_VALIDITY_RETURN_NULL(s, port != 0, AVAHI_ERR_INVALID_PORT); - AVAHI_CHECK_VALIDITY_RETURN_NULL(s, avahi_is_valid_domain_name(name), AVAHI_ERR_INVALID_HOST_NAME); + AVAHI_CHECK_VALIDITY_RETURN_NULL(s, avahi_is_valid_fqdn(name), AVAHI_ERR_INVALID_HOST_NAME); AVAHI_CHECK_VALIDITY_RETURN_NULL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME); if (!domain) @@ -1011,6 +1019,11 @@ void avahi_s_entry_group_change_state(AvahiSEntryGroup *g, AvahiEntryGroupState if (avahi_age(&g->established_at) > 5000000) g->n_register_try = 0; + } else if (g->state == AVAHI_ENTRY_GROUP_REGISTERING) { + if (g->register_time_event) { + avahi_time_event_free(g->register_time_event); + g->register_time_event = NULL; + } } if (state == AVAHI_ENTRY_GROUP_ESTABLISHED) @@ -1083,18 +1096,17 @@ static void entry_group_commit_real(AvahiSEntryGroup *g) { avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_REGISTERING); - if (!g->dead) { - avahi_announce_group(g->server, g); - avahi_s_entry_group_check_probed(g, 0); - } + if (g->dead) + return; + + avahi_announce_group(g->server, g); + avahi_s_entry_group_check_probed(g, 0); } static void entry_group_register_time_event_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* userdata) { AvahiSEntryGroup *g = userdata; assert(g); -/* avahi_log_debug("Holdoff passed, waking up and going on."); */ - avahi_time_event_free(g->register_time_event); g->register_time_event = NULL; @@ -1111,6 +1123,9 @@ int avahi_s_entry_group_commit(AvahiSEntryGroup *g) { if (g->state != AVAHI_ENTRY_GROUP_UNCOMMITED && g->state != AVAHI_ENTRY_GROUP_COLLISION) return avahi_server_set_errno(g->server, AVAHI_ERR_BAD_STATE); + if (avahi_s_entry_group_is_empty(g)) + return avahi_server_set_errno(g->server, AVAHI_ERR_IS_EMPTY); + g->n_register_try++; avahi_timeval_add(&g->register_time, @@ -1121,12 +1136,10 @@ int avahi_s_entry_group_commit(AvahiSEntryGroup *g) { gettimeofday(&now, NULL); if (avahi_timeval_compare(&g->register_time, &now) <= 0) { - /* Holdoff time passed, so let's start probing */ -/* avahi_log_debug("Holdoff passed, directly going on."); */ + /* Holdoff time passed, so let's start probing */ entry_group_commit_real(g); } else { -/* avahi_log_debug("Holdoff not passed, sleeping."); */ /* Holdoff time has not yet passed, so let's wait */ assert(!g->register_time_event); @@ -1150,15 +1163,8 @@ void avahi_s_entry_group_reset(AvahiSEntryGroup *g) { } g->server->need_entry_cleanup = 1; - if (g->register_time_event) { - avahi_time_event_free(g->register_time_event); - g->register_time_event = NULL; - } - g->n_probing = 0; - gettimeofday(&g->register_time, NULL); - avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_UNCOMMITED); }