mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Limit max open fds to 20K.
This commit is contained in:
parent
1efa17cf23
commit
be77094235
12
nnn.c
12
nnn.c
|
@ -246,10 +246,16 @@ max_openfds()
|
||||||
rl.rlim_cur = rl.rlim_max;
|
rl.rlim_cur = rl.rlim_max;
|
||||||
|
|
||||||
/* Return ~75% of max possible */
|
/* Return ~75% of max possible */
|
||||||
if (setrlimit(RLIMIT_NOFILE, &rl) == 0)
|
if (setrlimit(RLIMIT_NOFILE, &rl) == 0) {
|
||||||
return (rl.rlim_max - (rl.rlim_max >> 2));
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue