autofs-5.0.9 - make negative cache update consistent for all lookup modules From: Ian Kent Use common function for negative cache update everywhere to ensure consistency. --- CHANGELOG | 1 + modules/lookup_hosts.c | 14 +------------- modules/lookup_nisplus.c | 13 +------------ modules/lookup_program.c | 14 +------------- 4 files changed, 4 insertions(+), 38 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9b16bc6..b81a2cd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ - fix fix master map type check. - init qdn before use in get_query_dn(). - fix typo in update_hosts_mounts(). +- make negative cache update consistent for all lookup modules. 28/03/2014 autofs-5.0.9 ======================= diff --git a/modules/lookup_hosts.c b/modules/lookup_hosts.c index 407cf31..02bf970 100644 --- a/modules/lookup_hosts.c +++ b/modules/lookup_hosts.c @@ -149,22 +149,10 @@ static int do_parse_mount(struct autofs_point *ap, struct map_source *source, ret = ctxt->parse->parse_mount(ap, name, name_len, mapent, ctxt->parse->context); if (ret) { - time_t now = time(NULL); struct mapent_cache *mc = source->mc; - struct mapent *me; - int rv = CHE_OK; cache_writelock(mc); - me = cache_lookup_distinct(mc, name); - if (me) - rv = cache_push_mapent(me, NULL); - else - rv = cache_update(mc, source, name, NULL, now); - if (rv != CHE_FAIL) { - me = cache_lookup_distinct(mc, name); - if (me) - me->status = now + ap->negative_timeout; - } + cache_update_negative(mc, source, name, ap->negative_timeout); cache_unlock(mc); return NSS_STATUS_TRYAGAIN; } diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c index 42c9ccc..9301a21 100644 --- a/modules/lookup_nisplus.c +++ b/modules/lookup_nisplus.c @@ -594,24 +594,13 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void * ret = ctxt->parse->parse_mount(ap, key, key_len, mapent, ctxt->parse->context); if (ret) { - time_t now = time(NULL); - int rv = CHE_OK; - free(mapent); /* Don't update negative cache when re-connecting */ if (ap->flags & MOUNT_FLAG_REMOUNT) return NSS_STATUS_TRYAGAIN; cache_writelock(mc); - me = cache_lookup_distinct(mc, key); - if (me) - rv = cache_push_mapent(me, NULL); - else - rv = cache_update(mc, source, key, NULL, now); - if (rv != CHE_FAIL) { - me = cache_lookup_distinct(mc, key); - me->status = time(NULL) + ap->negative_timeout; - } + cache_update_negative(mc, source, key, ap->negative_timeout); cache_unlock(mc); return NSS_STATUS_TRYAGAIN; } diff --git a/modules/lookup_program.c b/modules/lookup_program.c index 6ce94e4..e40b177 100644 --- a/modules/lookup_program.c +++ b/modules/lookup_program.c @@ -448,20 +448,8 @@ out_free: free(mapent); if (ret) { - time_t now = time(NULL); - int rv = CHE_OK; - cache_writelock(mc); - me = cache_lookup_distinct(mc, name); - if (me) - rv = cache_push_mapent(me, NULL); - else - rv = cache_update(mc, source, name, NULL, now); - if (rv != CHE_FAIL) { - me = cache_lookup_distinct(mc, name); - if (me) - me->status = now + ap->negative_timeout; - } + cache_update_negative(mc, source, name, ap->negative_timeout); cache_unlock(mc); return NSS_STATUS_TRYAGAIN; }