Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 130701790bf2d95e902edf16031ff596 > files > 92

autofs-5.0.1-0.rc2.164.el5_8.src.rpm

autofs-5.0.1 - fix stale map read

From: Ian Kent <raven@themaw.net>

A previous patch to fix direct maps not updating on re-read has
a side effect of causing maps to always be re-read on lookup.
This is because, following the application of the previous patch,
the map stale status is no longer being updated on a successful
map read.
---

 daemon/lookup.c  |    1 +
 daemon/state.c   |    1 -
 include/master.h |    1 +
 lib/master.c     |   37 +++++++++++++++++++++++++------------
 4 files changed, 27 insertions(+), 13 deletions(-)


--- autofs-5.0.1.orig/daemon/lookup.c
+++ autofs-5.0.1/daemon/lookup.c
@@ -1118,6 +1118,7 @@ int lookup_prune_cache(struct autofs_poi
 		cache_readlock(map->mc);
 		lookup_prune_one_cache(ap, map->mc, age);
 		pthread_cleanup_pop(1);
+		clear_stale_instances(map);
 		map->stale = 0;
 		map = map->next;
 	}
--- autofs-5.0.1.orig/daemon/state.c
+++ autofs-5.0.1/daemon/state.c
@@ -502,7 +502,6 @@ static void *do_readmap(void *arg)
 		pthread_cleanup_pop(1);
 		pthread_cleanup_pop(1);
 		pthread_cleanup_pop(1);
-		lookup_prune_cache(ap, now);
 	}
 
 	pthread_cleanup_pop(1);
--- autofs-5.0.1.orig/include/master.h
+++ autofs-5.0.1/include/master.h
@@ -88,6 +88,7 @@ struct map_source *
 master_find_source_instance(struct map_source *, const char *, const char *, int, const char **);
 struct map_source *
 master_add_source_instance(struct map_source *, const char *, const char *, time_t, int, const char **);
+void clear_stale_instances(struct map_source *);
 void send_map_update_request(struct autofs_point *);
 void master_source_writelock(struct master_mapent *);
 void master_source_readlock(struct master_mapent *);
--- autofs-5.0.1.orig/lib/master.c
+++ autofs-5.0.1/lib/master.c
@@ -468,7 +468,26 @@ master_add_source_instance(struct map_so
 	return new;
 }
 
-static void check_stale_instances(struct map_source *source)
+static int check_stale_instances(struct map_source *source)
+{
+	struct map_source *map;
+
+	if (!source)
+		return 0;
+
+	map = source->instance;
+	while (map) {
+		if (map->stale)
+			return 1;
+		if (check_stale_instances(map))
+			return 1;
+		map = map->next;
+	}
+
+	return 0;
+}
+
+void clear_stale_instances(struct map_source *source)
 {
 	struct map_source *map;
 
@@ -477,11 +496,9 @@ static void check_stale_instances(struct
 
 	map = source->instance;
 	while (map) {
-		if (map->stale) {
-			source->stale = 1;
-			break;
-		}
-		check_stale_instances(map->instance);
+		clear_stale_instances(map);
+		if (map->stale)
+			map->stale = 0;
 		map = map->next;
 	}
 
@@ -502,12 +519,8 @@ void send_map_update_request(struct auto
 
 	map = ap->entry->maps;
 	while (map) {
-		check_stale_instances(map);
-		map = map->next;
-	}
-
-	map = ap->entry->maps;
-	while (map) {
+		if (check_stale_instances(map))
+			map->stale = 1;
 		if (map->stale) {
 			need_update = 1;
 			break;