Blame SOURCES/autofs-5.1.3-reset-master-map-list-on-startup-retry.patch

603f99
autofs-5.1.3 - reset master map list on startup retry
603f99
603f99
From: Ian Kent <raven@themaw.net>
603f99
603f99
On autofs startup if automount thinks the master map read failed
603f99
for some reason it retries the read after waiting for a fairly
603f99
short delay.
603f99
603f99
It should be ok to retry with the entries seen so far but there
603f99
may be cases where that causes problems so release any existing
603f99
master map entries before retrying.
603f99
603f99
Signed-off-by: Ian Kent <raven@themaw.net>
603f99
---
603f99
 CHANGELOG          |    1 +
603f99
 daemon/automount.c |   25 +++++++++++++++++++++++++
603f99
 2 files changed, 26 insertions(+)
603f99
603f99
--- autofs-5.0.7.orig/CHANGELOG
603f99
+++ autofs-5.0.7/CHANGELOG
603f99
@@ -265,6 +265,7 @@
603f99
 - make map source reference message debug only.
603f99
 - handle additional nfs versions in mount_nfs.c.
603f99
 - improve description of mount_nfs_default_protocol.
603f99
+- reset master map list on startup retry.
603f99
 
603f99
 25/07/2012 autofs-5.0.7
603f99
 =======================
603f99
--- autofs-5.0.7.orig/daemon/automount.c
603f99
+++ autofs-5.0.7/daemon/automount.c
603f99
@@ -2099,6 +2099,27 @@ static void remove_empty_args(char **arg
603f99
 	*argc = j;
603f99
 }
603f99
 
603f99
+static void do_master_list_reset(struct master *master)
603f99
+{
603f99
+	struct list_head *head, *p;
603f99
+
603f99
+	master_mutex_lock();
603f99
+
603f99
+	head = &master->mounts;
603f99
+	list_for_each(p, head) {
603f99
+		struct master_mapent *entry;
603f99
+
603f99
+		entry = list_entry(p, struct master_mapent, list);
603f99
+
603f99
+		if (!list_empty(&entry->list))
603f99
+			list_del(&entry->list);
603f99
+		master_free_mapent_sources(entry, 1);
603f99
+		master_free_mapent(entry);
603f99
+	}
603f99
+
603f99
+	master_mutex_unlock();
603f99
+}
603f99
+
603f99
 static int do_master_read_master(struct master *master, int wait)
603f99
 {
603f99
 	sigset_t signalset;
603f99
@@ -2118,6 +2139,8 @@ static int do_master_read_master(struct
603f99
 	while (1) {
603f99
 		struct timespec t = { retry_wait, 0 };
603f99
 
603f99
+		do_master_list_reset(master);
603f99
+
603f99
 		age = time(NULL);
603f99
 		if (master_read_master(master, age, 0)) {
603f99
 			ret = 1;
603f99
@@ -2586,6 +2609,8 @@ int main(int argc, char *argv[])
603f99
 			 * Failed to read master map, continue with what
603f99
 			 * we have anyway.
603f99
 			 */
603f99
+			do_master_list_reset(master_list);
603f99
+			age = time(NULL);
603f99
 			master_read_master(master_list, age, 1);
603f99
 		}
603f99
 	}