<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/9882">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Joshua Colp: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip: Resolve transport management leak at shutdown.<br><br>Cleanup idle check scheduled events at shutdown.<br><br>Change-Id: I61bfbb56bac69fe840c3242927d31ff3593be461<br>---<br>M res/res_pjsip/pjsip_transport_management.c<br>1 file changed, 27 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip/pjsip_transport_management.c b/res/res_pjsip/pjsip_transport_management.c</span><br><span>index d9866f1..e7483e6 100644</span><br><span>--- a/res/res_pjsip/pjsip_transport_management.c</span><br><span>+++ b/res/res_pjsip/pjsip_transport_management.c</span><br><span>@@ -119,10 +119,8 @@</span><br><span> </span><br><span> AST_THREADSTORAGE(desc_storage);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static int idle_sched_cb(const void *data)</span><br><span style="color: hsl(120, 100%, 40%);">+static int idle_sched_init_pj_thread(void)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- struct monitored_transport *monitored = (struct monitored_transport *) data;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> if (!pj_thread_is_registered()) {</span><br><span> pj_thread_t *thread;</span><br><span> pj_thread_desc *desc;</span><br><span>@@ -130,8 +128,7 @@</span><br><span> desc = ast_threadstorage_get(&desc_storage, sizeof(pj_thread_desc));</span><br><span> if (!desc) {</span><br><span> ast_log(LOG_ERROR, "Could not get thread desc from thread-local storage.\n");</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(monitored, -1);</span><br><span style="color: hsl(0, 100%, 40%);">- return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span> }</span><br><span> </span><br><span> pj_bzero(*desc, sizeof(*desc));</span><br><span>@@ -139,6 +136,18 @@</span><br><span> pj_thread_register("Transport Monitor", *desc, &thread);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static int idle_sched_cb(const void *data)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct monitored_transport *monitored = (struct monitored_transport *) data;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (idle_sched_init_pj_thread()) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(monitored, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (!monitored->sip_received) {</span><br><span> ast_log(LOG_NOTICE, "Shutting down transport '%s' since no request was received in %d seconds\n",</span><br><span> monitored->transport->info, IDLE_TIMEOUT / 1000);</span><br><span>@@ -149,6 +158,18 @@</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static int idle_sched_cleanup(const void *data)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct monitored_transport *monitored = (struct monitored_transport *) data;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!idle_sched_init_pj_thread()) {</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_transport_shutdown(monitored->transport);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(monitored, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! \brief Destructor for keepalive transport */</span><br><span> static void monitored_transport_destroy(void *obj)</span><br><span> {</span><br><span>@@ -384,6 +405,7 @@</span><br><span> </span><br><span> internal_sip_unregister_service(&idle_monitor_module);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sched_clean_by_callback(sched, idle_sched_cb, idle_sched_cleanup);</span><br><span> ast_sched_context_destroy(sched);</span><br><span> sched = NULL;</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9882">change 9882</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/9882"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I61bfbb56bac69fe840c3242927d31ff3593be461 </div>
<div style="display:none"> Gerrit-Change-Number: 9882 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>