diff --git a/channels/chan_sip.c b/channels/chan_sip.c index e42d78ff6f..ab511a0927 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -24737,6 +24737,10 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req) } else { transmit_response(p, "200 OK", req); } + + /* Destroy any pending invites so we won't try to do another + * scheduled reINVITE. */ + AST_SCHED_DEL_UNREF(sched, p->waitid, dialog_unref(p, "decrement refcount from sip_destroy because waitid won't be scheduled")); return 1; } diff --git a/contrib/scripts/safe_asterisk b/contrib/scripts/safe_asterisk index deb018eb32..90f804ed58 100644 --- a/contrib/scripts/safe_asterisk +++ b/contrib/scripts/safe_asterisk @@ -63,12 +63,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"