<blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">The timer must be stopped before the call to pjsip_inv_answer<br>as<br>pjsip_inv_answer is what is modifying the tdata (and thus<br>causing<br>the re transmission timer to get in an infinite loop)<br>To be more precise pjsip_inv_answer calls pjsip_dlg_modify_response<br>on the inv->last_answer which is the same tdata object as the<br>tsx->last_tx being used by the re-transmission timer.  so<br>pjsip_inv_answer can not be called safely while any<br>re-transmission<br>timer is active</p></blockquote></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">That makes sense.  However, it would make more sense for<br>pjsip_inv_answer() to cancel the timer itself since there are three<br>places in chan_pjsip.c that call pjsip_inv_answer() and the<br>deadlock can happen for any response after we send 100 trying.</p><p style="white-space: pre-wrap; word-wrap: break-word;">In the pjsip/src/pjsip/sip_transaction.c:tsx_on_state_proceeding_uas()<br>function it calls:</p><p style="white-space: pre-wrap; word-wrap: break-word;">/* Stop 1xx retransmission timer, if any */<br>tsx_cancel_timer(tsx, &tsx->retransmit_timer);</p><p style="white-space: pre-wrap; word-wrap: break-word;">Where tsx can be obtained from pjsip_inv_answer()'s<br>inv->invite_tsx.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Which is effectively the same thing as pjsip_tsx_stop_retransmit().</p><p style="white-space: pre-wrap; word-wrap: break-word;"><br>Unfortunately, I don't think this will completely eliminate the<br>deadlock because the timer callback could already be running in the<br>monitor thread when you try to cancel the timer.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">Actually it should be safe as the both the timer and the cancel timer both take the group lock on tsx.</p><p><a href="https://gerrit.asterisk.org/9477">View Change</a></p><ul style="list-style: none; padding: 0;"></ul><p>To view, visit <a href="https://gerrit.asterisk.org/9477">change 9477</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/9477"/><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: comment </div>
<div style="display:none"> Gerrit-Change-Id: Ic381004a3a212fe1d8eca0e707fe09dba4a6ab4e </div>
<div style="display:none"> Gerrit-Change-Number: 9477 </div>
<div style="display:none"> Gerrit-PatchSet: 8 </div>
<div style="display:none"> Gerrit-Owner: Torrey Searle <tsearle@gmail.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: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Torrey Searle <tsearle@gmail.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Wed, 25 Jul 2018 15:57:48 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>
<div style="display:none"> Gerrit-HasLabels: No </div>