aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-08-21 00:55:45 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-08-21 09:16:11 +0530
commitbe77094235269c0c95f0459535c20ba68c8845bf (patch)
tree4383c510e9e30e27a52d230ce67b4b7697c6165f
parent1efa17cf232df8c4de2c9d060891044bcbcd7c62 (diff)
downloadnnn-be77094235269c0c95f0459535c20ba68c8845bf.tar.gz
Limit max open fds to 20K.
-rw-r--r--nnn.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/nnn.c b/nnn.c
index 4605d19..4199fee 100644
--- a/nnn.c
+++ b/nnn.c
@@ -246,10 +246,16 @@ max_openfds()
rl.rlim_cur = rl.rlim_max;
/* Return ~75% of max possible */
- if (setrlimit(RLIMIT_NOFILE, &rl) == 0)
- return (rl.rlim_max - (rl.rlim_max >> 2));
+ if (setrlimit(RLIMIT_NOFILE, &rl) == 0) {
+ limit = rl.rlim_max - (rl.rlim_max >> 2);
+ /*
+ * 20K is arbitrary> If the limit is set to max possible
+ * value, the memory usage increases to more than double.
+ */
+ return limit > 20480 ? 20480 : limit;
+ }
- return 32;
+ return limit;
}
/*