Ian Kent a26132
autofs-5.1.4 - fix monotonic_elapsed
Ian Kent a26132
Ian Kent a26132
From: NeilBrown <neilb@suse.com>
Ian Kent a26132
Ian Kent a26132
When automount probes multiple hosts to find the one which
Ian Kent a26132
responds most quickly, it currently ignores the nanoseconds.
Ian Kent a26132
This often makes the cost "0", which makes weights ineffective.
Ian Kent a26132
Ian Kent a26132
The cause is that monotonic_elapsed() casts tv_nsec to a
Ian Kent a26132
double *after* dividing by 1 billion, rather than before.
Ian Kent a26132
Ian Kent a26132
With this change, weights become effective for choosing
Ian Kent a26132
between hosts which respond in under one second.
Ian Kent a26132
Ian Kent a26132
Signed-off-by: NeilBrown <neilb@suse.com>
Ian Kent a26132
Signed-off-by: Ian Kent <raven@themaw.net>
Ian Kent a26132
---
Ian Kent a26132
 CHANGELOG      |    1 +
Ian Kent a26132
 lib/rpc_subs.c |    4 ++--
Ian Kent a26132
 2 files changed, 3 insertions(+), 2 deletions(-)
Ian Kent a26132
Ian Kent a26132
diff --git a/CHANGELOG b/CHANGELOG
Ian Kent a26132
index 104fca90..313730b1 100644
Ian Kent a26132
--- a/CHANGELOG
Ian Kent a26132
+++ b/CHANGELOG
Ian Kent a26132
@@ -10,6 +10,7 @@ xx/xx/2018 autofs-5.1.5
Ian Kent a26132
 - add error handling for ext_mount_add().
Ian Kent a26132
 - account for recent libnsl changes.
Ian Kent a26132
 - use_hostname_for_mounts shouldn't prevent selection among replicas.
Ian Kent a26132
+- fix monotonic_elapsed.
Ian Kent a26132
 
Ian Kent a26132
 19/12/2017 autofs-5.1.4
Ian Kent a26132
 - fix spec file url.
Ian Kent a26132
diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c
Ian Kent a26132
index 73097c9d..60ede9f8 100644
Ian Kent a26132
--- a/lib/rpc_subs.c
Ian Kent a26132
+++ b/lib/rpc_subs.c
Ian Kent a26132
@@ -1093,9 +1093,9 @@ double monotonic_elapsed(struct timespec start, struct timespec end)
Ian Kent a26132
 	double t1, t2;
Ian Kent a26132
 
Ian Kent a26132
 	t1 =  (double) start.tv_sec +
Ian Kent a26132
-		(double) (start.tv_nsec/(1000*1000*1000));
Ian Kent a26132
+		((double) start.tv_nsec/(1000*1000*1000));
Ian Kent a26132
 	t2 =  (double) end.tv_sec +
Ian Kent a26132
-		(double) (end.tv_nsec/(1000*1000*1000));
Ian Kent a26132
+		((double) end.tv_nsec/(1000*1000*1000));
Ian Kent a26132
 	return t2 - t1;
Ian Kent a26132
 }
Ian Kent a26132