Blame SOURCES/autofs-5.0.7-use-ulimit-max-open-files-if-greater-than-internal-maximum.patch

304803
autofs-5.0.7 - use ulimit max open files if greater than internal maximum
304803
304803
From: Ian Kent <raven@themaw.net>
304803
304803
When setting the maximum number of allowed file handles the current setting
304803
should be checked before setting it. If the ulimit command has been used to
304803
increase the maximum to larger than what automount would ask for then honour
304803
it.
304803
---
304803
 daemon/automount.c |    7 +++++--
304803
 1 file changed, 5 insertions(+), 2 deletions(-)
304803
304803
diff --git a/daemon/automount.c b/daemon/automount.c
304803
index 019637f..1d0b64e 100644
304803
--- a/daemon/automount.c
304803
+++ b/daemon/automount.c
304803
@@ -2106,8 +2106,11 @@ int main(int argc, char *argv[])
304803
 		exit(1);
304803
 	}
304803
 
304803
-	rlim.rlim_cur = MAX_OPEN_FILES;
304803
-	rlim.rlim_max = MAX_OPEN_FILES;
304803
+	res = getrlimit(RLIMIT_NOFILE, &rlim);
304803
+	if (res == -1 || rlim.rlim_max <= MAX_OPEN_FILES)  {
304803
+		rlim.rlim_cur = MAX_OPEN_FILES;
304803
+		rlim.rlim_max = MAX_OPEN_FILES;
304803
+	}
304803
 	res = setrlimit(RLIMIT_NOFILE, &rlim);
304803
 	if (res)
304803
 		printf("%s: can't increase open file limit - continuing",