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

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