Allow limitation by loadavg not just calls (should be BSD friendly)...

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6850 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2005-10-26 03:58:32 +00:00
parent f2dcf45a98
commit 0b36348b12
5 changed files with 35 additions and 3 deletions

9
pbx.c
View File

@@ -2477,7 +2477,7 @@ out:
static int increase_call_count(const struct ast_channel *c)
{
int failed = 0;
double curloadavg;
ast_mutex_lock(&maxcalllock);
if (option_maxcalls) {
if (countcalls >= option_maxcalls) {
@@ -2485,6 +2485,13 @@ static int increase_call_count(const struct ast_channel *c)
failed = -1;
}
}
if (option_maxload) {
getloadavg(&curloadavg, 1);
if (curloadavg >= option_maxload) {
ast_log(LOG_NOTICE, "Maximum loadavg limit of %lf load exceeded by '%s' (currently %f)!\n", option_maxload, c->name, curloadavg);
failed = -1;
}
}
if (!failed)
countcalls++;
ast_mutex_unlock(&maxcalllock);