Blame SOURCES/autofs-5.0.7-dont-schedule-new-alarms-after-readmap.patch

4d476f
autofs-5.0.7 - don't schedule new alarms after readmap
4d476f
4d476f
From: Leonardo Chiquitto <leonardo.lists@gmail.com>
4d476f
4d476f
Currently, a new alarm is scheduled every time the daemon receives
4d476f
a SIGHUP (map re-read) or SIGUSR1 (forced expiration). Besides that,
4d476f
map re-reads started on demand when a map is found to be outdated
4d476f
also generate a new alarm.
4d476f
4d476f
Once added, these alarms are never deleted and hence increase the
4d476f
number of times the daemon wakes up to run the expiration procedure.
4d476f
After a couple of months, in setups with many mount points, it's
4d476f
normal to see automount waking up every second to handle the
4d476f
expiration timer.
4d476f
4d476f
This patch removes the alarm scheduling from the readmap cleanup
4d476f
routine and makes sure the alarm is re-added after the expiration
4d476f
process only when it was not triggered by SIGUSR1.
4d476f
4d476f
I couldn't think of any use case to justify keeping these alarms:
4d476f
it's critical to have the alarm ticking every timeout/4 seconds,
4d476f
but more than one periodic alarm running doesn't seem to make
4d476f
sense.
4d476f
---
4d476f
4d476f
 CHANGELOG      |    1 +
4d476f
 daemon/state.c |    6 +-----
4d476f
 2 files changed, 2 insertions(+), 5 deletions(-)
4d476f
4d476f
4d476f
diff --git a/CHANGELOG b/CHANGELOG
4d476f
index c9be73e..4cf5621 100644
4d476f
--- a/CHANGELOG
4d476f
+++ b/CHANGELOG
4d476f
@@ -22,6 +22,7 @@
4d476f
 - fix init script status return.
4d476f
 - fix use get_proximity() without libtirpc.
4d476f
 - don't use dirent d_type to filter out files in scandir()
4d476f
+- don't schedule new alarms after readmap.
4d476f
 
4d476f
 25/07/2012 autofs-5.0.7
4d476f
 =======================
4d476f
diff --git a/daemon/state.c b/daemon/state.c
4d476f
index b451c56..6e23022 100644
4d476f
--- a/daemon/state.c
4d476f
+++ b/daemon/state.c
4d476f
@@ -144,7 +144,7 @@ void expire_cleanup(void *arg)
4d476f
 					ap->submount = 2;
4d476f
 			}
4d476f
 
4d476f
-			if (!ap->submount)
4d476f
+			if (ap->state == ST_EXPIRE && !ap->submount)
4d476f
 				alarm_add(ap, ap->exp_runfreq);
4d476f
 
4d476f
 			/* FALLTHROUGH */
4d476f
@@ -330,13 +330,9 @@ static void do_readmap_cleanup(void *arg)
4d476f
 	ap = ra->ap;
4d476f
 
4d476f
 	st_mutex_lock();
4d476f
-
4d476f
 	ap->readmap_thread = 0;
4d476f
 	st_set_done(ap);
4d476f
-	if (!ap->submount)
4d476f
-		alarm_add(ap, ap->exp_runfreq);
4d476f
 	st_ready(ap);
4d476f
-
4d476f
 	st_mutex_unlock();
4d476f
 
4d476f
 	free(ra);