<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][16962] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=16962">16962</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2010-03-10 14:21:34 -0600 (Wed, 10 Mar 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>add fsctl min_idle_cpu and min-idle-cpu feature to refuse calls after the system fallse below a certian percentage of idle cpu</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunkMakefileam">freeswitch/trunk/Makefile.am</a></li>
<li><a href="#freeswitchtrunksrcincludeprivateswitch_core_pvth">freeswitch/trunk/src/include/private/switch_core_pvt.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_coreh">freeswitch/trunk/src/include/switch_core.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_typesh">freeswitch/trunk/src/include/switch_types.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_commandsmod_commandsc">freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_corec">freeswitch/trunk/src/switch_core.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_sessionc">freeswitch/trunk/src/switch_core_session.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_timec">freeswitch/trunk/src/switch_time.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunkMakefileam"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/Makefile.am (16961 => 16962)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/Makefile.am        2010-03-10 17:04:00 UTC (rev 16961)
+++ freeswitch/trunk/Makefile.am        2010-03-10 20:21:34 UTC (rev 16962)
</span><span class="lines">@@ -228,6 +228,7 @@
</span><span class="cx">         src/switch_odbc.c \
</span><span class="cx">         src/g711.c \
</span><span class="cx">         src/switch_pcm.c \
</span><ins>+        src/switch_profile.c\
</ins><span class="cx">         libs/stfu/stfu.c \
</span><span class="cx">         libs/libteletone/src/libteletone_detect.c \
</span><span class="cx">         libs/libteletone/src/libteletone_generate.c \
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeprivateswitch_core_pvth"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h (16961 => 16962)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/private/switch_core_pvt.h        2010-03-10 17:04:00 UTC (rev 16961)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h        2010-03-10 20:21:34 UTC (rev 16962)
</span><span class="lines">@@ -31,6 +31,9 @@
</span><span class="cx"> * this file does not exist!!!!
</span><span class="cx"> *
</span><span class="cx"> */
</span><ins>+
+#include "switch_profile.h"
+
</ins><span class="cx"> #ifndef WIN32
</span><span class="cx"> #include <switch_private.h>
</span><span class="cx"> #endif
</span><span class="lines">@@ -220,6 +223,9 @@
</span><span class="cx">         uint32_t runlevel;
</span><span class="cx">         uint32_t tipping_point;
</span><span class="cx">         int32_t timer_affinity;
</span><ins>+        switch_profile_timer_t *profile_timer;
+        double profile_time;
+        double min_idle_time;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> extern struct switch_runtime runtime;
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_coreh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_core.h (16961 => 16962)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_core.h        2010-03-10 17:04:00 UTC (rev 16961)
+++ freeswitch/trunk/src/include/switch_core.h        2010-03-10 20:21:34 UTC (rev 16962)
</span><span class="lines">@@ -1901,7 +1901,7 @@
</span><span class="cx"> \param val the command arguement (if needed)
</span><span class="cx"> \return 0 on success nonzero on error
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t *val);
</del><ins>+SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, void *val);
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> \brief Get the output console
</span><span class="lines">@@ -1970,6 +1970,8 @@
</span><span class="cx"> SWITCH_DECLARE(void) switch_time_set_cond_yield(switch_bool_t enable);
</span><span class="cx"> SWITCH_DECLARE(uint32_t) switch_core_min_dtmf_duration(uint32_t duration);
</span><span class="cx"> SWITCH_DECLARE(uint32_t) switch_core_max_dtmf_duration(uint32_t duration);
</span><ins>+SWITCH_DECLARE(double) switch_core_min_idle_cpu(double new_limit);
+SWITCH_DECLARE(double) switch_core_idle_cpu(void);
</ins><span class="cx"> SWITCH_DECLARE(uint32_t) switch_core_default_dtmf_duration(uint32_t duration);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_console_set_alias(const char *string);
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_typesh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_types.h (16961 => 16962)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_types.h        2010-03-10 17:04:00 UTC (rev 16961)
+++ freeswitch/trunk/src/include/switch_types.h        2010-03-10 20:21:34 UTC (rev 16962)
</span><span class="lines">@@ -1458,7 +1458,8 @@
</span><span class="cx">         SCSC_SHUTDOWN_NOW,
</span><span class="cx">         SCSC_CALIBRATE_CLOCK,
</span><span class="cx">         SCSC_SAVE_HISTORY,
</span><del>-        SCSC_CRASH
</del><ins>+        SCSC_CRASH,
+        SCSC_MIN_IDLE_CPU
</ins><span class="cx"> } switch_session_ctl_t;
</span><span class="cx">
</span><span class="cx"> typedef enum {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_commandsmod_commandsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (16961 => 16962)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c        2010-03-10 17:04:00 UTC (rev 16961)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c        2010-03-10 20:21:34 UTC (rev 16962)
</span><span class="lines">@@ -1439,6 +1439,7 @@
</span><span class="cx">         switch_core_session_ctl(SCSC_SPS, &sps);
</span><span class="cx">         stream->write_function(stream, "%d session(s) %d/%d\n", switch_core_session_count(), last_sps, sps);
</span><span class="cx">         stream->write_function(stream, "%d session(s) max\n", switch_core_session_limit(0));
</span><ins>+        stream->write_function(stream, "min idle cpu %0.2f/%0.2f\n", switch_core_min_idle_cpu(-1.0), switch_core_idle_cpu());
</ins><span class="cx">
</span><span class="cx">         if (html) {
</span><span class="cx">                 stream->write_function(stream, "</b>\n");
</span><span class="lines">@@ -1535,7 +1536,23 @@
</span><span class="cx">                                 arg = atoi(argv[1]);
</span><span class="cx">                         }
</span><span class="cx">                         switch_core_session_ctl(SCSC_MAX_SESSIONS, &arg);
</span><del>-                        stream->write_function(stream, "+OK max sessions: %d\n", arg);
</del><ins>+                        stream->write_function(stream, "+OK max sessions: %f\n", arg);
+                } else if (!strcasecmp(argv[0], "min_idle_cpu")) {
+                        double d = -1;
+                        
+                        if (argc > 1) {
+                                d = atof(argv[1]);
+                        }
+
+                        switch_core_session_ctl(SCSC_MIN_IDLE_CPU, &d);
+
+                        if (d) {
+                                stream->write_function(stream, "+OK min idle cpu: %0.2f%\n", d);
+                        } else {
+                                stream->write_function(stream, "+OK min idle cpu: DISABLED\n", d);
+                        }
+
+                        
</ins><span class="cx">                 } else if (!strcasecmp(argv[0], "max_dtmf_duration")) {
</span><span class="cx">                         if (argc > 1) {
</span><span class="cx">                                 arg = atoi(argv[1]);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_corec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core.c (16961 => 16962)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core.c        2010-03-10 17:04:00 UTC (rev 16961)
+++ freeswitch/trunk/src/switch_core.c        2010-03-10 20:21:34 UTC (rev 16962)
</span><span class="lines">@@ -82,6 +82,7 @@
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Count", "%u", switch_core_session_count());
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Per-Sec", "%u", runtime.sps);
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Since-Startup", "%" SWITCH_SIZE_T_FMT, switch_core_session_id() - 1);
</span><ins>+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Idle-CPU", "%f", switch_core_idle_cpu());
</ins><span class="cx">                 switch_event_fire(&event);
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -1442,6 +1443,8 @@
</span><span class="cx">                                         switch_time_set_matrix(switch_true(var));
</span><span class="cx">                                 } else if (!strcasecmp(var, "max-sessions") && !zstr(val)) {
</span><span class="cx">                                         switch_core_session_limit(atoi(val));
</span><ins>+                                } else if (!strcasecmp(var, "min-idle-cpu") && !zstr(val)) {
+                                        switch_core_min_idle_cpu(atof(val));
</ins><span class="cx">                                 } else if (!strcasecmp(var, "tipping-point") && !zstr(val)) {
</span><span class="cx">                                         runtime.tipping_point = atoi(val);
</span><span class="cx">                                 } else if (!strcasecmp(var, "timer-affinity") && !zstr(val)) {
</span><span class="lines">@@ -1628,8 +1631,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t *val)
</del><ins>+SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, void *val)
</ins><span class="cx"> {
</span><ins>+        int *intval = (int *) val;
+
</ins><span class="cx">         if (switch_test_flag((&runtime), SCF_SHUTTING_DOWN)) {
</span><span class="cx">                 return -1;
</span><span class="cx">         }
</span><span class="lines">@@ -1646,10 +1651,10 @@
</span><span class="cx">                 break;
</span><span class="cx">         case SCSC_SYNC_CLOCK:
</span><span class="cx">                 switch_time_sync();
</span><del>-                *val = 0;
</del><ins>+                *intval = 0;
</ins><span class="cx">                 break;
</span><span class="cx">         case SCSC_PAUSE_INBOUND:
</span><del>-                if (*val) {
</del><ins>+                if (*intval) {
</ins><span class="cx">                         switch_set_flag((&runtime), SCF_NO_NEW_SESSIONS);
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_clear_flag((&runtime), SCF_NO_NEW_SESSIONS);
</span><span class="lines">@@ -1700,7 +1705,7 @@
</span><span class="cx">                                 win_shutdown();
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-                                if (*val) {
</del><ins>+                                if (*intval) {
</ins><span class="cx">                                         switch_set_flag((&runtime), SCF_RESTART);
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Restarting\n");
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -1722,7 +1727,7 @@
</span><span class="cx">                 win_shutdown();
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-                if (*val) {
</del><ins>+                if (*intval) {
</ins><span class="cx">                         switch_set_flag((&runtime), SCF_RESTART);
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Restarting\n");
</span><span class="cx">                 } else {
</span><span class="lines">@@ -1734,53 +1739,59 @@
</span><span class="cx">                 runtime.running = 0;
</span><span class="cx">                 break;
</span><span class="cx">         case SCSC_CHECK_RUNNING:
</span><del>-                *val = runtime.running;
</del><ins>+                *intval = runtime.running;
</ins><span class="cx">                 break;
</span><span class="cx">         case SCSC_LOGLEVEL:
</span><del>-                if (*val > -1) {
-                        runtime.hard_log_level = *val;
</del><ins>+                if (*intval > -1) {
+                        runtime.hard_log_level = *intval;
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (runtime.hard_log_level > SWITCH_LOG_DEBUG) {
</span><span class="cx">                         runtime.hard_log_level = SWITCH_LOG_DEBUG;
</span><span class="cx">                 }
</span><del>-                *val = runtime.hard_log_level;
</del><ins>+                *intval = runtime.hard_log_level;
</ins><span class="cx">                 break;
</span><span class="cx">         case SCSC_DEBUG_LEVEL:
</span><del>-                if (*val > -1) {
-                        if (*val > 10)
-                                *val = 10;
-                        runtime.debug_level = *val;
</del><ins>+                if (*intval > -1) {
+                        if (*intval > 10)
+                                *intval = 10;
+                        runtime.debug_level = *intval;
</ins><span class="cx">                 }
</span><del>-                *val = runtime.debug_level;
</del><ins>+                *intval = runtime.debug_level;
</ins><span class="cx">                 break;
</span><ins>+        case SCSC_MIN_IDLE_CPU:
+                {
+                        double *dval = (double *) val;
+                        *dval = switch_core_min_idle_cpu(*dval);
+                }
+                break;
</ins><span class="cx">         case SCSC_MAX_SESSIONS:
</span><del>-                *val = switch_core_session_limit(*val);
</del><ins>+                *intval = switch_core_session_limit(*intval);
</ins><span class="cx">                 break;
</span><span class="cx">         case SCSC_LAST_SPS:
</span><del>-                *val = runtime.sps_last;
</del><ins>+                *intval = runtime.sps_last;
</ins><span class="cx">                 break;
</span><span class="cx">         case SCSC_MAX_DTMF_DURATION:
</span><del>-                *val = switch_core_max_dtmf_duration(*val);
</del><ins>+                *intval = switch_core_max_dtmf_duration(*intval);
</ins><span class="cx">                 break;
</span><span class="cx">         case SCSC_MIN_DTMF_DURATION:
</span><del>-                *val = switch_core_min_dtmf_duration(*val);
</del><ins>+                *intval = switch_core_min_dtmf_duration(*intval);
</ins><span class="cx">                 break;
</span><span class="cx">         case SCSC_DEFAULT_DTMF_DURATION:
</span><del>-                *val = switch_core_default_dtmf_duration(*val);
</del><ins>+                *intval = switch_core_default_dtmf_duration(*intval);
</ins><span class="cx">                 break;
</span><span class="cx">         case SCSC_SPS:
</span><span class="cx">                 switch_mutex_lock(runtime.throttle_mutex);
</span><del>-                if (*val > 0) {
-                        runtime.sps_total = *val;
</del><ins>+                if (*intval > 0) {
+                        runtime.sps_total = *intval;
</ins><span class="cx">                 }
</span><del>-                *val = runtime.sps_total;
</del><ins>+                *intval = runtime.sps_total;
</ins><span class="cx">                 switch_mutex_unlock(runtime.throttle_mutex);
</span><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">         case SCSC_RECLAIM:
</span><span class="cx">                 switch_core_memory_reclaim_all();
</span><del>-                *val = 0;
</del><ins>+                *intval = 0;
</ins><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_sessionc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_session.c (16961 => 16962)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_session.c        2010-03-10 17:04:00 UTC (rev 16961)
+++ freeswitch/trunk/src/switch_core_session.c        2010-03-10 20:21:34 UTC (rev 16962)
</span><span class="lines">@@ -1485,6 +1485,10 @@
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if (runtime.min_idle_time > 0 && runtime.profile_time < runtime.min_idle_time) {
+                return NULL;
+        }
+
</ins><span class="cx">         PROTECT_INTERFACE(endpoint_interface);
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(runtime.throttle_mutex);
</span><span class="lines">@@ -1640,6 +1644,21 @@
</span><span class="cx">         return session_manager.session_limit;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+SWITCH_DECLARE(double) switch_core_min_idle_cpu(double new_limit)
+{
+        if (new_limit >= 0) {
+                runtime.min_idle_time = new_limit;
+        }
+
+        return runtime.min_idle_time;
+}
+
+
+SWITCH_DECLARE(double) switch_core_idle_cpu(void)
+{
+        return runtime.profile_time;
+}
+
</ins><span class="cx"> SWITCH_DECLARE(uint32_t) switch_core_sessions_per_second(uint32_t new_limit)
</span><span class="cx"> {
</span><span class="cx">         if (new_limit) {
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_timec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_time.c (16961 => 16962)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_time.c        2010-03-10 17:04:00 UTC (rev 16961)
+++ freeswitch/trunk/src/switch_time.c        2010-03-10 20:21:34 UTC (rev 16962)
</span><span class="lines">@@ -630,7 +630,11 @@
</span><span class="cx">         uint32_t x, tick = 0;
</span><span class="cx">         switch_time_t ts = 0, last = 0;
</span><span class="cx">         int fwd_errs = 0, rev_errs = 0;
</span><ins>+        int profile_tick = 0;
</ins><span class="cx">
</span><ins>+        runtime.profile_timer = switch_new_profile_timer();
+        switch_get_system_idle_time(runtime.profile_timer, &runtime.profile_time);
+
</ins><span class="cx"> #ifdef HAVE_CPU_SET_MACROS
</span><span class="cx">         if (runtime.timer_affinity > -1) {
</span><span class="cx">                 cpu_set_t set;
</span><span class="lines">@@ -741,6 +745,11 @@
</span><span class="cx">                 tick += STEP_MS;
</span><span class="cx">
</span><span class="cx">                 if (tick >= TICK_PER_SEC) {
</span><ins>+                        if (++profile_tick == 1) {
+                                switch_get_system_idle_time(runtime.profile_timer, &runtime.profile_time);
+                                profile_tick = 0;
+                        }
+                        
</ins><span class="cx">                         if (runtime.sps <= 0) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Over Session Rate of %d!\n", runtime.sps_total);
</span><span class="cx">                         }
</span><span class="lines">@@ -803,6 +812,8 @@
</span><span class="cx">         globals.RUNNING = 0;
</span><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><span class="cx">
</span><ins>+        switch_delete_profile_timer(&runtime.profile_timer);
+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Soft timer thread exiting.\n");
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_TERM;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>