From 62256ee410915750eb4bbf249af1d418e0c0540e Mon Sep 17 00:00:00 2001 From: "Dwayne M. Hubbard" Date: Wed, 11 Apr 2007 19:11:32 +0000 Subject: added option_minmemfree for use in asterisk.conf to specify the amount of minimum free memory prior to accepting calls. added CLI 'core show sysinfo' to display system information git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61539 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/pbx.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'main/pbx.c') diff --git a/main/pbx.c b/main/pbx.c index ef9567850..0f82e9a56 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -37,6 +37,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include #include #include +#include #include "asterisk/lock.h" #include "asterisk/cli.h" @@ -2447,11 +2448,14 @@ static int __ast_pbx_run(struct ast_channel *c) return 0; } -/* Returns 0 on success, non-zero if call limit was reached */ +/* Returns 0 on success, non-zero if a configured limit (maxcalls, maxload, minmemfree) was reached */ static int increase_call_count(const struct ast_channel *c) { int failed = 0; double curloadavg; + long curfreemem; + struct sysinfo sys_info; + ast_mutex_lock(&maxcalllock); if (option_maxcalls) { if (countcalls >= option_maxcalls) { @@ -2466,6 +2470,19 @@ static int increase_call_count(const struct ast_channel *c) failed = -1; } } + if (option_minmemfree) { + if (!sysinfo(&sys_info)) { + /* make sure that the free system memory is above the configured low watermark + * convert the amount of freeram from mem_units to MB */ + curfreemem = sys_info.freeram / sys_info.mem_unit; + curfreemem /= 1024*1024; + if (curfreemem < option_minmemfree) { + ast_log(LOG_WARNING, "Available system memory (~%ldMB) is below the configured low watermark (%ldMB)\n", curfreemem, option_minmemfree); + failed = -1; + } + } + } + if (!failed) countcalls++; ast_mutex_unlock(&maxcalllock); -- cgit v1.2.3