<p style="white-space: pre-wrap; word-wrap: break-word;">I'm sorry, I mixed up initid and waitid in my reasoning above:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">    p->waitid = ast_sched_add(sched, wait, sip_reinvite_retry, p);<br>    if (p->waitid < 0) {<br>        /* Uh Oh.  Expect bad behavior. */<br>        dialog_ref(p, "Failed to schedule waitid"); // <-- this is not supposed to happen though, and see [5]<br>...<br>    AST_SCHED_DEL_UNREF(sched, p->initid, dialog_unref(p, "when you delete the initid sched, you should dec the refcount for the stored dialog ptr"));</pre></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">That should've been:</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">        AST_SCHED_DEL_UNREF(sched, dialog->waitid,<br>                dialog_unref(dialog, "Stop scheduled waitid"));</pre><p style="white-space: pre-wrap; word-wrap: break-word;">I accidentally started looking at initid while browsing the source. The "waitid" schedule does not do a AST_SCHED_REPLACE_UNREF as well, so it does not mix always-clean-up vs. clean-up-only-if-scheduled semantics, which I incorrectly suggested it did.</p><p style="white-space: pre-wrap; word-wrap: break-word;">The rest of my argument still stands though.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/10991">View Change</a></p><ul style="list-style: none; padding: 0;"></ul><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/10991">change 10991</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/+/10991"/><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-Change-Id: Ic26777fa0732725e6ca7010df17af77a012aa856 </div>
<div style="display:none"> Gerrit-Change-Number: 10991 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Walter Doekes <walter+asterisk@wjd.nu> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Walter Doekes <walter+asterisk@wjd.nu> </div>
<div style="display:none"> Gerrit-Reviewer: mattf <creslin@digium.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Tue, 12 Mar 2019 09:42:39 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Gerrit-MessageType: comment </div>