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

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