[asterisk-bugs] [Asterisk 0017124]: minmemfree does not work

Asterisk Bug Tracker noreply at bugs.digium.com
Thu Apr 1 08:59:01 CDT 2010


The following issue has been SUBMITTED. 
====================================================================== 
https://issues.asterisk.org/view.php?id=17124 
====================================================================== 
Reported By:                loic
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   17124
Category:                   Core/PBX
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
Asterisk Version:           1.6.2.6 
JIRA:                        
Regression:                 No 
Reviewboard Link:            
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2010-04-01 08:59 CDT
Last Modified:              2010-04-01 08:59 CDT
====================================================================== 
Summary:                    minmemfree does not work
Description: 
When you set minmemfree option in asterisk.conf and you place a call, you
have already this error :
pbx.c:4501 increase_call_count: Available system memory (~1129MB) is below
the configured low watermark (*your minmemfree parameter*MB)
chan_sip.c:20305 handle_request_invite: Failed to start PBX (call limit
reached)

There is an error in the calculation of available memory in main.pbx.c.
To avoid that, I replace "curfreemem = sys_info.freeram /
sys_info.mem_unit;" by "curfreemem = sys_info.freeram * sys_info.mem_unit;"
in function increase_call_count.

The good code :
static int increase_call_count(const struct ast_channel *c)
{
        int failed = 0;
        double curloadavg;
#if defined(HAVE_SYSINFO)
        long curfreemem;
        struct sysinfo sys_info;
#endif

        ast_mutex_lock(&maxcalllock);
        if (option_maxcalls) {
                if (countcalls >= option_maxcalls) {
                        ast_log(LOG_WARNING, "Maximum call limit of %d
calls exceeded by '%s'!\n", option_maxcalls, c->name);
                        failed = -1;
                }
        }
        if (option_maxload) {
                getloadavg(&curloadavg, 1);
                if (curloadavg >= option_maxload) {
                        ast_log(LOG_WARNING, "Maximum loadavg limit of %f
load exceeded by '%s' (currently %f)!\n", option_maxload, c->name,
curloadavg);
                        failed = -1;
                }
        }
#if defined(HAVE_SYSINFO)
        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;
                        }
                }
        }
#endif

        if (!failed) {
                countcalls++;
                totalcalls++;
        }
        ast_mutex_unlock(&maxcalllock);

        return failed;
}

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2010-04-01 08:59 loic           New Issue                                    
2010-04-01 08:59 loic           Asterisk Version          => 1.6.2.6         
2010-04-01 08:59 loic           Regression                => No              
2010-04-01 08:59 loic           SVN Branch (only for SVN checkouts, not tarball
releases) => N/A             
======================================================================




More information about the asterisk-bugs mailing list