autofs/autofs-5.0.7-use-ulimit-max-open-files-if-greater-than-internal-maximum.patch
Ian Kent d7489ff43a - add upstream patch to only probe specific protocol if given as an option.
- add upstream patch to respect ulimit setting if it is greater than the limit to be requested.
2013-07-10 09:51:09 +08:00

31 lines
990 B
Diff

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