autofs/autofs-5.1.8-fix-set-open-file-limit.patch
2022-01-09 12:16:28 +08:00

58 lines
1.8 KiB
Diff

autofs-5.1.8 - fix set open file limit
From: Ian Kent <raven@themaw.net>
The check of whether the open file limit needs to be changed is not
right, it checks the hard open file limit against what autofs wants
to set it to which is always less than this value. Consequently the
open file limit isn't changed.
autofs should be changing only the soft open file limit but it is
setting both the hard and soft limits. The system hard limit is much
higer than the autofs maximum open files so the hard limit should be
left alone.
While we are here increase the requested maximum soft open file limit
to 20k.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/automount.c | 7 ++++---
2 files changed, 5 insertions(+), 3 deletions(-)
--- autofs-5.1.7.orig/CHANGELOG
+++ autofs-5.1.7/CHANGELOG
@@ -82,6 +82,7 @@
- use default stack size for threads.
- fix kernel mount status notification.
- fix fedfs build flags.
+- fix set open file limit.
25/01/2021 autofs-5.1.7
- make bind mounts propagation slave by default.
--- autofs-5.1.7.orig/daemon/automount.c
+++ autofs-5.1.7/daemon/automount.c
@@ -94,7 +94,7 @@ struct startup_cond suc = {
pthread_key_t key_thread_stdenv_vars;
pthread_key_t key_thread_attempt_id = (pthread_key_t) 0L;
-#define MAX_OPEN_FILES 10240
+#define MAX_OPEN_FILES 20480
int aquire_flag_file(void);
void release_flag_file(void);
@@ -2483,9 +2483,10 @@ int main(int argc, char *argv[])
}
res = getrlimit(RLIMIT_NOFILE, &rlim);
- if (res == -1 || rlim.rlim_max <= MAX_OPEN_FILES) {
+ if (res == -1 || rlim.rlim_cur <= MAX_OPEN_FILES) {
rlim.rlim_cur = MAX_OPEN_FILES;
- rlim.rlim_max = MAX_OPEN_FILES;
+ if (rlim.rlim_max < MAX_OPEN_FILES)
+ rlim.rlim_max = MAX_OPEN_FILES;
}
res = setrlimit(RLIMIT_NOFILE, &rlim);
if (res)