provide an alternate getloadavg implementation and a fallback for systems that don't have it at all (issue #5549 with minor mods)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6903 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2005-10-31 21:25:21 +00:00
parent f9c8bb8087
commit c3f9388b23
2 changed files with 48 additions and 7 deletions

View File

@@ -1874,7 +1874,12 @@ static void ast_readconfig(void) {
option_maxcalls = 0;
}
} else if (!strcasecmp(v->name, "maxload")) {
if ((sscanf(v->value, "%lf", &option_maxload) != 1) || (option_maxload < 0.0)) {
double test[1];
if (getloadavg(test, 1) == -1) {
ast_log(LOG_ERROR, "Cannot obtain load average on this system. 'maxload' option disabled.\n");
option_maxload = 0.0;
} else if ((sscanf(v->value, "%lf", &option_maxload) != 1) || (option_maxload < 0.0)) {
option_maxload = 0.0;
}
}