Blame SOURCES/autofs-5.1.8-dont-immediately-call-function-when-waiting.patch

288172
autofs-5.1.8 - dont immediately call function when waiting
288172
288172
From: Ian Kent <raven@themaw.net>
288172
288172
When autofs needs to wait for a sss connection the connection function
288172
is immediately called a second time without first waiting. Adjust the
288172
calling so that there's a wait before the next call.
288172
288172
Signed-off-by: Ian Kent <raven@themaw.net>
288172
---
288172
 CHANGELOG            |    1 +
288172
 modules/lookup_sss.c |   24 ++++++++++++------------
288172
 2 files changed, 13 insertions(+), 12 deletions(-)
288172
288172
--- autofs-5.1.4.orig/CHANGELOG
288172
+++ autofs-5.1.4/CHANGELOG
288172
@@ -107,6 +107,7 @@
288172
 - fix incorrect path for is_mounted() in try_remount().
288172
 - fail on empty replicated host name.
288172
 - improve handling of ENOENT in sss setautomntent().
288172
+- don't immediately call function when waiting.
288172
 
288172
 xx/xx/2018 autofs-5.1.5
288172
 - fix flag file permission.
288172
--- autofs-5.1.4.orig/modules/lookup_sss.c
288172
+++ autofs-5.1.4/modules/lookup_sss.c
288172
@@ -338,10 +338,13 @@ static int setautomntent_wait(unsigned i
288172
 	     "can't connect to sssd, retry for %d seconds",
288172
 	     retries);
288172
 
288172
-	while (++retry <= retries) {
288172
+	while (++retry < retries) {
288172
 		struct timespec t = { SSS_WAIT_INTERVAL, 0 };
288172
 		struct timespec r;
288172
 
288172
+		while (nanosleep(&t, &r) == -1 && errno == EINTR)
288172
+			memcpy(&t, &r, sizeof(struct timespec));
288172
+
288172
 		ret = ctxt->setautomntent(ctxt->mapname, sss_ctxt);
288172
 		if (proto_version(ctxt) == 0) {
288172
 			if (ret != ENOENT)
288172
@@ -355,9 +358,6 @@ static int setautomntent_wait(unsigned i
288172
 			free(*sss_ctxt);
288172
 			*sss_ctxt = NULL;
288172
 		}
288172
-
288172
-		while (nanosleep(&t, &r) == -1 && errno == EINTR)
288172
-			memcpy(&t, &r, sizeof(struct timespec));
288172
 	}
288172
 
288172
 	if (!ret)
288172
@@ -475,10 +475,13 @@ static int getautomntent_wait(unsigned i
288172
 	 "can't contact sssd to to get map entry, retry for %d seconds",
288172
 	 retries);
288172
 
288172
-	while (++retry <= retries) {
288172
+	while (++retry < retries) {
288172
 		struct timespec t = { SSS_WAIT_INTERVAL, 0 };
288172
 		struct timespec r;
288172
 
288172
+		while (nanosleep(&t, &r) == -1 && errno == EINTR)
288172
+			memcpy(&t, &r, sizeof(struct timespec));
288172
+
288172
 		ret = ctxt->getautomntent_r(key, value, sss_ctxt);
288172
 		if (proto_version(ctxt) == 0) {
288172
 			if (ret != ENOENT)
288172
@@ -487,9 +490,6 @@ static int getautomntent_wait(unsigned i
288172
 			if (ret != EHOSTDOWN)
288172
 				break;
288172
 		}
288172
-
288172
-		while (nanosleep(&t, &r) == -1 && errno == EINTR)
288172
-			memcpy(&t, &r, sizeof(struct timespec));
288172
 	}
288172
 
288172
 	if (!ret)
288172
@@ -600,10 +600,13 @@ static int getautomntbyname_wait(unsigne
288172
 	"can't contact sssd to to lookup key value, retry for %d seconds",
288172
 	retries);
288172
 
288172
-	while (++retry <= retries) {
288172
+	while (++retry < retries) {
288172
 		struct timespec t = { SSS_WAIT_INTERVAL, 0 };
288172
 		struct timespec r;
288172
 
288172
+		while (nanosleep(&t, &r) == -1 && errno == EINTR)
288172
+			memcpy(&t, &r, sizeof(struct timespec));
288172
+
288172
 		ret = ctxt->getautomntbyname_r(key, value, sss_ctxt);
288172
 		if (proto_version(ctxt) == 0) {
288172
 			if (ret != ENOENT)
288172
@@ -612,9 +615,6 @@ static int getautomntbyname_wait(unsigne
288172
 			if (ret != EHOSTDOWN)
288172
 				break;
288172
 		}
288172
-
288172
-		while (nanosleep(&t, &r) == -1 && errno == EINTR)
288172
-			memcpy(&t, &r, sizeof(struct timespec));
288172
 	}
288172
 
288172
 	if (!ret)