Blob Blame History Raw
autofs-5.1.3 - reset master map list on startup retry

From: Ian Kent <raven@themaw.net>

On autofs startup if automount thinks the master map read failed
for some reason it retries the read after waiting for a fairly
short delay.

It should be ok to retry with the entries seen so far but there
may be cases where that causes problems so release any existing
master map entries before retrying.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG          |    1 +
 daemon/automount.c |   25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

--- autofs-5.0.7.orig/CHANGELOG
+++ autofs-5.0.7/CHANGELOG
@@ -265,6 +265,7 @@
 - make map source reference message debug only.
 - handle additional nfs versions in mount_nfs.c.
 - improve description of mount_nfs_default_protocol.
+- reset master map list on startup retry.
 
 25/07/2012 autofs-5.0.7
 =======================
--- autofs-5.0.7.orig/daemon/automount.c
+++ autofs-5.0.7/daemon/automount.c
@@ -2099,6 +2099,27 @@ static void remove_empty_args(char **arg
 	*argc = j;
 }
 
+static void do_master_list_reset(struct master *master)
+{
+	struct list_head *head, *p;
+
+	master_mutex_lock();
+
+	head = &master->mounts;
+	list_for_each(p, head) {
+		struct master_mapent *entry;
+
+		entry = list_entry(p, struct master_mapent, list);
+
+		if (!list_empty(&entry->list))
+			list_del(&entry->list);
+		master_free_mapent_sources(entry, 1);
+		master_free_mapent(entry);
+	}
+
+	master_mutex_unlock();
+}
+
 static int do_master_read_master(struct master *master, int wait)
 {
 	sigset_t signalset;
@@ -2118,6 +2139,8 @@ static int do_master_read_master(struct
 	while (1) {
 		struct timespec t = { retry_wait, 0 };
 
+		do_master_list_reset(master);
+
 		age = time(NULL);
 		if (master_read_master(master, age, 0)) {
 			ret = 1;
@@ -2586,6 +2609,8 @@ int main(int argc, char *argv[])
 			 * Failed to read master map, continue with what
 			 * we have anyway.
 			 */
+			do_master_list_reset(master_list);
+			age = time(NULL);
 			master_read_master(master_list, age, 1);
 		}
 	}