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

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