Blame SOURCES/autofs-5.1.0-make-negative-cache-update-consistent-for-all-lookup-modules.patch

306fa1
autofs-5.1.0 - make negative cache update consistent for all lookup modules
306fa1
306fa1
From: Ian Kent <ikent@redhat.com>
306fa1
306fa1
Use common function for negative cache update everywhere to ensure consistency.
306fa1
---
306fa1
 CHANGELOG                |    1 +
306fa1
 modules/lookup_hosts.c   |   14 +-------------
306fa1
 modules/lookup_nisplus.c |   13 +------------
306fa1
 modules/lookup_program.c |   14 +-------------
306fa1
 4 files changed, 4 insertions(+), 38 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -159,6 +159,7 @@
306fa1
 - fix fix master map type check.
306fa1
 - fix typo in update_hosts_mounts().
306fa1
 - fix hosts map update on reload.
306fa1
+- make negative cache update consistent for all lookup modules.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/modules/lookup_hosts.c
306fa1
+++ autofs-5.0.7/modules/lookup_hosts.c
306fa1
@@ -149,22 +149,10 @@ static int do_parse_mount(struct autofs_
306fa1
 	ret = ctxt->parse->parse_mount(ap, name, name_len,
306fa1
 				 mapent, ctxt->parse->context);
306fa1
 	if (ret) {
306fa1
-		time_t now = time(NULL);
306fa1
 		struct mapent_cache *mc = source->mc;
306fa1
-		struct mapent *me;
306fa1
-		int rv = CHE_OK;
306fa1
 
306fa1
 		cache_writelock(mc);
306fa1
-		me = cache_lookup_distinct(mc, name);
306fa1
-		if (me)
306fa1
-			rv = cache_push_mapent(me, NULL);
306fa1
-		else
306fa1
-			rv = cache_update(mc, source, name, NULL, now);
306fa1
-		if (rv != CHE_FAIL) {
306fa1
-			me = cache_lookup_distinct(mc, name);
306fa1
-			if (me)
306fa1
-				me->status = now + ap->negative_timeout;
306fa1
-		}
306fa1
+		cache_update_negative(mc, source, name, ap->negative_timeout);
306fa1
 		cache_unlock(mc);
306fa1
 		return NSS_STATUS_TRYAGAIN;
306fa1
 	}
306fa1
--- autofs-5.0.7.orig/modules/lookup_nisplus.c
306fa1
+++ autofs-5.0.7/modules/lookup_nisplus.c
306fa1
@@ -777,24 +777,13 @@ int lookup_mount(struct autofs_point *ap
306fa1
 	ret = ctxt->parse->parse_mount(ap, key, key_len,
306fa1
 				       mapent, ctxt->parse->context);
306fa1
 	if (ret) {
306fa1
-		time_t now = time(NULL);
306fa1
-		int rv = CHE_OK;
306fa1
-
306fa1
 		free(mapent);
306fa1
 
306fa1
 		/* Don't update negative cache when re-connecting */
306fa1
 		if (ap->flags & MOUNT_FLAG_REMOUNT)
306fa1
 			return NSS_STATUS_TRYAGAIN;
306fa1
 		cache_writelock(mc);
306fa1
-		me = cache_lookup_distinct(mc, key);
306fa1
-		if (me)
306fa1
-			rv = cache_push_mapent(me, NULL);
306fa1
-		else
306fa1
-			rv = cache_update(mc, source, key, NULL, now);
306fa1
-		if (rv != CHE_FAIL) {
306fa1
-			me = cache_lookup_distinct(mc, key);
306fa1
-			me->status = time(NULL) + ap->negative_timeout;
306fa1
-		}
306fa1
+		cache_update_negative(mc, source, key, ap->negative_timeout);
306fa1
 		cache_unlock(mc);
306fa1
 		return NSS_STATUS_TRYAGAIN;
306fa1
 	}
306fa1
--- autofs-5.0.7.orig/modules/lookup_program.c
306fa1
+++ autofs-5.0.7/modules/lookup_program.c
306fa1
@@ -622,20 +622,8 @@ out_free:
306fa1
 		free(mapent);
306fa1
 
306fa1
 	if (ret) {
306fa1
-		time_t now = time(NULL);
306fa1
-		int rv = CHE_OK;
306fa1
-
306fa1
 		cache_writelock(mc);
306fa1
-		me = cache_lookup_distinct(mc, name);
306fa1
-		if (me)
306fa1
-			rv = cache_push_mapent(me, NULL);
306fa1
-		else
306fa1
-			rv = cache_update(mc, source, name, NULL, now);
306fa1
-		if (rv != CHE_FAIL) {
306fa1
-			me = cache_lookup_distinct(mc, name);
306fa1
-			if (me)
306fa1
-				me->status = now + ap->negative_timeout;
306fa1
-		}
306fa1
+		cache_update_negative(mc, source, name, ap->negative_timeout);
306fa1
 		cache_unlock(mc);
306fa1
 		return NSS_STATUS_TRYAGAIN;
306fa1
 	}