summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorWalter Doekes <walter+asterisk@wjd.nu>2014-10-09 08:10:35 +0000
committerWalter Doekes <walter+asterisk@wjd.nu>2014-10-09 08:10:35 +0000
commitd0255c4a4663712b22645c00041bec1181c63ac5 (patch)
tree789894e1dbc9e614065de6ac1257ff87e31b8ac0 /contrib
parent8b0089ea1dd8a50d7583d5c09b120fa4490853c6 (diff)
safe_asterisk: Don't automatically exceed MAXFILES value of 2^20.
On systems with lots of RAM (e.g. 24GB) /proc/sys/fs/file-max divided by two can exceed the per-process file limit of 2^20. This patch ensures the value is capped. (Patch cleaned up by me.) ASTERISK-24011 #close Reported by: Michael Myles Patches: safe_asterisk-ulimit.diff uploaded by Michael Myles (License #6626) ........ Merged revisions 424875 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 424878 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 424879 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 424880 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@424881 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'contrib')
-rw-r--r--contrib/scripts/safe_asterisk11
1 files changed, 8 insertions, 3 deletions
diff --git a/contrib/scripts/safe_asterisk b/contrib/scripts/safe_asterisk
index de24d1b28..62f3dadc2 100644
--- a/contrib/scripts/safe_asterisk
+++ b/contrib/scripts/safe_asterisk
@@ -67,12 +67,17 @@ if test `id -u` != 0; then
message "safe_asterisk was started by `id -n` (uid `id -u`)."
else
if `uname -s | grep Linux >/dev/null 2>&1`; then
- # maximum number of open files is set to the system maximum divided by two if
- # MAXFILES is not set.
+ # maximum number of open files is set to the system maximum
+ # divided by two if MAXFILES is not set.
if test -z "$MAXFILES"; then
# just check if file-max is readable
if test -r /proc/sys/fs/file-max; then
- MAXFILES=$(( `cat /proc/sys/fs/file-max` / 2 ))
+ MAXFILES=$((`cat /proc/sys/fs/file-max` / 2))
+ # don't exceed upper limit of 2^20 for open
+ # files on systems where file-max is > 2^21
+ if test $MAXFILES -gt 1048576; then
+ MAXFILES=1048576
+ fi
fi
fi
SYSCTL_MAXFILES="fs.file-max"