X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-core%2Fcache.c;h=9d97b6cd0a55ab01fbb609ba164529e848112cbf;hb=23ca50a5a56b6ea98a73480cff50ebb73ecba7ca;hp=3a8f849ba98c9f41e13e16b067f10a3d7dc72c54;hpb=a3d45b39608418e261f34b3b3286b80e4878d25c;p=catta diff --git a/avahi-core/cache.c b/avahi-core/cache.c index 3a8f849..9d97b6c 100644 --- a/avahi-core/cache.c +++ b/avahi-core/cache.c @@ -444,12 +444,15 @@ void avahi_cache_flush(AvahiCache *c) { static void* start_poof_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, void *userdata) { AvahiAddress *a = userdata; + struct timeval now; assert(c); assert(pattern); assert(e); assert(a); - + + gettimeofday(&now, NULL); + switch (e->state) { case AVAHI_CACHE_VALID: @@ -458,15 +461,23 @@ static void* start_poof_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEnt e->state = AVAHI_CACHE_POOF; e->poof_address = *a; - + e->poof_timestamp = now; + e->poof_num = 0; + break; case AVAHI_CACHE_POOF: + if (avahi_timeval_diff(&now, &e->poof_timestamp) < 1000000) + break; - /* This is the second time we got no response, so let's + e->poof_timestamp = now; + e->poof_address = *a; + e->poof_num ++; + + /* This is the 4th time we got no response, so let's * fucking remove this entry. */ - - expire_in_one_second(c, e, AVAHI_CACHE_POOF_FINAL); + if (e->poof_num > 3) + expire_in_one_second(c, e, AVAHI_CACHE_POOF_FINAL); break; default: @@ -480,7 +491,7 @@ void avahi_cache_start_poof(AvahiCache *c, AvahiKey *key, const AvahiAddress *a) assert(c); assert(key); - avahi_cache_walk(c, key, start_poof_callback, a); + avahi_cache_walk(c, key, start_poof_callback, (void*) a); } void avahi_cache_stop_poof(AvahiCache *c, AvahiRecord *record, const AvahiAddress *a) {