autofs-5.1.1 - fix direct map expire not set for initial empty map
From: Ian Kent <raven@themaw.net>
If an empty direct map is present at startup the expire alarm can't be
set because the expire run frequency isn't known. But if the map is
re-read and is no longer empty the expire alarm wasn't being set.
Fix suggested by xuw at redhat dot com, thanks.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/state.c | 10 ++++++++++
2 files changed, 11 insertions(+)
--- autofs-5.0.7.orig/CHANGELOG
+++ autofs-5.0.7/CHANGELOG
@@ -179,6 +179,7 @@
- make find_server() return a status.
- fix return handling of do_reconnect() in ldap module.
- fix direct mount stale instance flag reset.
+- fix direct map expire not set for initail empty map.
25/07/2012 autofs-5.0.7
=======================
--- autofs-5.0.7.orig/daemon/state.c
+++ autofs-5.0.7/daemon/state.c
@@ -488,6 +488,7 @@ static void *do_readmap(void *arg)
status = lookup_ghost(ap, ap->path);
} else {
struct mapent *me;
+ unsigned int append_alarm = !ap->exp_runfreq;
mnts = tree_make_mnt_tree(_PROC_MOUNTS, "/");
pthread_cleanup_push(tree_mnts_cleanup, mnts);
@@ -517,6 +518,15 @@ static void *do_readmap(void *arg)
map->stale = 0;
map = map->next;
}
+
+ /* If the direct mount map was empty at startup no expire
+ * alarm will have been added. So add it here if there are
+ * now map entries.
+ */
+ if (append_alarm && ap->exp_runfreq)
+ alarm_add(ap, ap->exp_runfreq +
+ rand() % ap->exp_runfreq);
+
pthread_cleanup_pop(1);
pthread_cleanup_pop(1);
pthread_cleanup_pop(1);