<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19322">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span></span><br></pre><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">manager: be more aggressive about purging http sessions.<br><br>If we find that n_max (currently hard wired to 1) sessions were purged,<br>schedule the next purge for 1ms into the future rather than 5000ms (as<br>per current). This way we will purge up to 1000 sessions per second<br>rather than 1 every 5 seconds.<br><br>This mitigates a build-up of sessions should http sessions gets<br>established faster than 1 per 5 seconds.<br><br>Change-Id: I9820d39aa080109df44fe98c1325cafae48d54f5<br>Signed-off-by: Jaco Kroon <jaco@uls.co.za><br>---<br>M main/manager.c<br>1 file changed, 34 insertions(+), 3 deletions(-)<br><br></pre>
<pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/manager.c b/main/manager.c</span><br><span>index eb0459e..90333a0 100644</span><br><span>--- a/main/manager.c</span><br><span>+++ b/main/manager.c</span><br><span>@@ -7014,16 +7014,17 @@</span><br><span> }</span><br><span> </span><br><span> /*! \brief remove at most n_max stale session from the list. */</span><br><span style="color: hsl(0, 100%, 40%);">-static void purge_sessions(int n_max)</span><br><span style="color: hsl(120, 100%, 40%);">+static int purge_sessions(int n_max)</span><br><span> {</span><br><span> struct ao2_container *sessions;</span><br><span> struct mansession_session *session;</span><br><span> time_t now = time(NULL);</span><br><span> struct ao2_iterator i;</span><br><span style="color: hsl(120, 100%, 40%);">+ int purged = 0;</span><br><span> </span><br><span> sessions = ao2_global_obj_ref(mgr_sessions);</span><br><span> if (!sessions) {</span><br><span style="color: hsl(0, 100%, 40%);">- return;</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span> }</span><br><span> i = ao2_iterator_init(sessions, 0);</span><br><span> ao2_ref(sessions, -1);</span><br><span>@@ -7039,12 +7040,14 @@</span><br><span> ao2_unlock(session);</span><br><span> session_destroy(session);</span><br><span> n_max--;</span><br><span style="color: hsl(120, 100%, 40%);">+ purged++;</span><br><span> } else {</span><br><span> ao2_unlock(session);</span><br><span> unref_mansession(session);</span><br><span> }</span><br><span> }</span><br><span> ao2_iterator_destroy(&i);</span><br><span style="color: hsl(120, 100%, 40%);">+ return purged;</span><br><span> }</span><br><span> </span><br><span> /*! \brief</span><br><span>@@ -8637,7 +8640,17 @@</span><br><span> */</span><br><span> static void purge_old_stuff(void *data)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- purge_sessions(1);</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_tcptls_session_args *ser = data;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* purge_sessions will return the number of sessions actually purged,</span><br><span style="color: hsl(120, 100%, 40%);">+ * up to a maximum of it's arguments, purge one at a time, keeping a</span><br><span style="color: hsl(120, 100%, 40%);">+ * purge interval of 1ms as long as we purged a session, otherwise</span><br><span style="color: hsl(120, 100%, 40%);">+ * revert to a purge check every 5s</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (purge_sessions(1) == 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ser->poll_timeout = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ ser->poll_timeout = 5000;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> purge_events();</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19322">change 19322</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/19322"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 19 </div>
<div style="display:none"> Gerrit-Change-Id: I9820d39aa080109df44fe98c1325cafae48d54f5 </div>
<div style="display:none"> Gerrit-Change-Number: 19322 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Jaco Kroon <jaco@uls.co.za> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>