X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-core%2Fcache.c;h=c26b6bb9d81225e592faf0b370b7cd877eb21a79;hb=da75d1898a45c106a994cd87f8da5b6bcb2b6450;hp=23e9036f48beda9256b43bcd3d39530ac3168fcb;hpb=6d236291b17f2d02e15d4c6f1c87bc7b3fc4e982;p=catta diff --git a/avahi-core/cache.c b/avahi-core/cache.c index 23e9036..c26b6bb 100644 --- a/avahi-core/cache.c +++ b/avahi-core/cache.c @@ -31,8 +31,9 @@ #include "cache.h" #include "log.h" +#include "rr-util.h" -#define AVAHI_MAX_CACHE_ENTRIES 500 +#define AVAHI_CACHE_ENTRIES_MAX 500 static void remove_entry(AvahiCache *c, AvahiCacheEntry *e) { AvahiCacheEntry *t; @@ -101,7 +102,7 @@ void avahi_cache_free(AvahiCache *c) { avahi_free(c); } -AvahiCacheEntry *avahi_cache_lookup_key(AvahiCache *c, AvahiKey *k) { +static AvahiCacheEntry *lookup_key(AvahiCache *c, AvahiKey *k) { assert(c); assert(k); @@ -131,7 +132,7 @@ void* avahi_cache_walk(AvahiCache *c, AvahiKey *pattern, AvahiCacheWalkCallback } else { AvahiCacheEntry *e, *n; - for (e = avahi_cache_lookup_key(c, pattern); e; e = n) { + for (e = lookup_key(c, pattern); e; e = n) { n = e->by_key_next; if ((ret = cb(c, pattern, e, userdata))) @@ -153,7 +154,7 @@ static void* lookup_record_callback(AvahiCache *c, AvahiKey *pattern, AvahiCache return NULL; } -AvahiCacheEntry *avahi_cache_lookup_record(AvahiCache *c, AvahiRecord *r) { +static AvahiCacheEntry *lookup_record(AvahiCache *c, AvahiRecord *r) { assert(c); assert(r); @@ -210,11 +211,9 @@ static void elapse_func(AvahiTimeEvent *t, void *userdata) { assert(percent > 0); - /* Request a cache update, if we are subscribed to this entry */ - if (avahi_querier_exists(e->cache->interface, e->record->key)) { -/* avahi_log_debug("Requesting cache entry update at %i%% for %s.", percent, txt); */ - avahi_interface_post_query(e->cache->interface, e->record->key, 1); - } + /* Request a cache update if we are subscribed to this entry */ + if (avahi_querier_shall_refresh_cache(e->cache->interface, e->record->key)) + avahi_interface_post_query(e->cache->interface, e->record->key, 0, NULL); /* Check again later */ next_expiry(e->cache, e, percent); @@ -279,7 +278,7 @@ void avahi_cache_update(AvahiCache *c, AvahiRecord *r, int cache_flush, const Av AvahiCacheEntry *e; - if ((e = avahi_cache_lookup_record(c, r))) + if ((e = lookup_record(c, r))) expire_in_one_second(c, e, AVAHI_CACHE_GOODBYE_FINAL); } else { @@ -290,7 +289,7 @@ void avahi_cache_update(AvahiCache *c, AvahiRecord *r, int cache_flush, const Av /* This is an update request */ - if ((first = avahi_cache_lookup_key(c, r->key))) { + if ((first = lookup_key(c, r->key))) { if (cache_flush) { @@ -331,7 +330,7 @@ void avahi_cache_update(AvahiCache *c, AvahiRecord *r, int cache_flush, const Av /* avahi_log_debug("cache: couldn't find matching cache entry for %s", txt); */ - if (c->n_entries >= AVAHI_MAX_CACHE_ENTRIES) + if (c->n_entries >= AVAHI_CACHE_ENTRIES_MAX) return; if (!(e = avahi_new(AvahiCacheEntry, 1))) { @@ -480,7 +479,7 @@ void avahi_cache_stop_poof(AvahiCache *c, AvahiRecord *record, const AvahiAddres assert(record); assert(a); - if (!(e = avahi_cache_lookup_record(c, record))) + if (!(e = lookup_record(c, record))) return; /* This function is called for each response suppression