<p> Attention is currently required from: Michael Bradeen, Joshua Colp. </p>
<p>Patch set 7:<span style="border-radius: 3px; display: inline-block; margin: 0 2px; padding: 4px;background-color: #ffd4d4; color: #000000;">Code-Review -1</span></p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17644">View Change</a></p><p>12 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="null">File include/asterisk/sched.h:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17644/comment/9c882918_150db312">Patch Set #7, Line 75:</a> <code style="font-family:monospace,monospace"> * Only calls unref function if the delete succeeded.</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">I think this could use additional clarification:</p><p style="white-space: pre-wrap; word-wrap: break-word;">"Only calls the unref function if the task is actually deleted by ast_sched_del_nonrunning. If a failure occurs, or the task is currently running and not rescheduled the unref function is not called."</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17644/comment/d748251b_fd1b7d23">Patch Set #7, Line 315:</a> <code style="font-family:monospace,monospace">* \retval -2 event was running and not rescheduled</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Reword this a bit to say something like "-2 event was running, but deleted via non rescheduling.</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="null">File main/sched.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17644/comment/5318d478_513a151f">Patch Set #2, Line 658:</a> <code style="font-family:monospace,monospace"> sched_release(con, s);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">"s" gets freed in sched_release, and should be set to NULL after calling sched_release since "s" is checked for NULL later in this function.</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="null">File main/sched.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17644/comment/1dce11b5_f7d37f1a">Patch Set #7, Line 666:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;"> /* This was not rescheduled so the caller of ast_sched_del can not remove any<br> * references as they already were.<br> */<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">I think this comment can be deleted. To me it is a bit out of context here as the scheduler has no knowledge of references, and does not manage user resources.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17644/comment/1edb6e80_fcf1ab19">Patch Set #7, Line 673:</a> <code style="font-family:monospace,monospace"> * it's destruction to us</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">s/it's/its</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17644/comment/7f38918c_b1855b50">Patch Set #7, Line 688:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;"> if (!s && *last_id != id) {<br> ast_debug(1, "Attempted to delete nonexistent schedule entry %d!\n", id);<br> /* Removing nonexistent schedule entry shouldn't trigger assert (it was enabled in DEV_MODE);<br> * because in many places entries is deleted without having valid id. */<br> *last_id = id;<br> return -1;<br> } else if (!s) {<br> return -1;<br> }<br><br> return res;<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">When you set "s" to NULL above this might need to be reworked as this function will now always return -1.</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="null">File tests/test_sched.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17644/comment/1f904c45_ac4d34d7">Patch Set #2, Line 366:</a> <code style="font-family:monospace,monospace"> usleep(3000);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">usleep can be interrupted, so this probably needs to be in a loop to ensure the full 3 seconds passes.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Example using nanosleep:</p><p style="white-space: pre-wrap; word-wrap: break-word;">; one second pause/delay<br>struct timespec delay = { 1, 0 };</p><p style="white-space: pre-wrap; word-wrap: break-word;">while (nanosleep(&delay, &delay));</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17644/comment/769f2b59_f07e36ec">Patch Set #2, Line 406:</a> <code style="font-family:monospace,monospace"> return AST_TEST_FAIL;</code></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">obj is leaked</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">obj still leaked.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17644/comment/7454c646_d4fb79e2">Patch Set #2, Line 412:</a> <code style="font-family:monospace,monospace"> return AST_TEST_FAIL;</code></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">obj is leaked</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">obj still leaked.</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="null">File tests/test_sched.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17644/comment/fa6f8671_f068e2bb">Patch Set #7, Line 405:</a> <code style="font-family:monospace,monospace"> ao2_ref(obj, +1);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">If you move this to just before sched_add then you'll no longer leak "obj" in the below off nominal paths.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17644/comment/8c86e2d3_4b64b355">Patch Set #7, Line 423:</a> <code style="font-family:monospace,monospace"> ao2_bump(obj);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">If you move the add ref above this can become ao2_ref(obj, +2);</p><p style="white-space: pre-wrap; word-wrap: break-word;">If you do that make sure to also add/keep the comment why the additional ref is needed.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/c/asterisk/+/17644/comment/aea91a47_b4b2ae00">Patch Set #7, Line 426:</a> <code style="font-family:monospace,monospace"> while(ao2_ref(obj, -1) > 1);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">If this fails you know you have 3 additional refs currently, so ao2_ref(obj, -3) should be sufficient. Also, to me it makes ref tracking more clear.</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17644">change 17644</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/+/17644"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Icfb16b3acbc29cf5b4cef74183f7531caaefe21d </div>
<div style="display:none"> Gerrit-Change-Number: 17644 </div>
<div style="display:none"> Gerrit-PatchSet: 7 </div>
<div style="display:none"> Gerrit-Owner: Michael Bradeen <mbradeen@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-Attention: Michael Bradeen <mbradeen@sangoma.com> </div>
<div style="display:none"> Gerrit-Attention: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Thu, 06 Jan 2022 19:10:58 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-Has-Labels: Yes </div>
<div style="display:none"> Comment-In-Reply-To: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: comment </div>