<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/1400/">https://reviewboard.asterisk.org/r/1400/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On August 30th, 2011, 2:55 p.m., <b>Alec Davis</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I believe we are dealling with 2 issues.
1). This fix, which catches the creation of dead channels, which is good.
2). Pickup which can invoke dead channels, which is what we're using to invoke them. Other situations may too.
I'm still in favour of the pickup datastore (or some similar method) on the caller channel to tidy up pickups of multiple legs of a single call, as was done for race detection of 2 channels picking up the exact same channel. Then we don't get to the masquerade which is too late.
The senario I've been using is;
Parent lets their kids go to school but tells them only one is allowed out after school.
Both kids are invited out by friends, both kids say yes.
Kids get home not knowing that the other has been invited out.
Parent who is the masquerader can only deliver 1 kid. It's too late.
Had the kids been able to ring parent with cell phone to check, all would have been ok, well at least the 2nd kid would have been told no.
</pre>
</blockquote>
<p>On August 30th, 2011, 3:53 p.m., <b>Alec Davis</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I shouldn't have used favour in my last comment. This fix is correct.
I should have used: in addition to this fix, we should somehow mark the parent caller channel 'as being picked up' so that the other legs are aware, but only for the duration of the pickup.
</pre>
</blockquote>
</blockquote>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">At any rate, it is definitely another patch. If it were implemented, the current datastore used to prevent picking up the same channel would not be needed since the parent channel mark would work for both situations. However, I'm not sure the effort and resource consumption to implement a parent channel mark would be worth it for the forked call corner case. The current behavior, from the losing pickup attempt point-of-view, is the same as if the caller hung up on the losing pickup attempt.</pre>
<br />
<p>- rmudgett</p>
<br />
<p>On August 30th, 2011, 2:28 p.m., rmudgett wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers, Alec Davis and irroot.</div>
<div>By rmudgett.</div>
<p style="color: grey;"><i>Updated Aug. 30, 2011, 2:28 p.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Attempting to pickup a call that has been forked to multiple extensions by two users either crashes or fails a masquerade with a "bad things may happen" message.
This is the scenario that is causing all the grief:
1) Pickup target is selected
2) target is marked as being picked up in ast_do_pickup()
3) target is unlocked by ast_do_pickup()
4) app dial or queue gets a chance to hang up losing calls and calls ast_hangup() on target
5) SINCE A MASQUERADE HAS NOT BEEN SETUP YET BY ast_do_pickup() with ast_channel_masquerade(), ast_hangup() completes successfully and the channel is no longer in the channels container.
6) ast_do_pickup() then calls ast_channel_masquerade() to schedule the masquerade on the dead channel.
7) ast_do_pickup() then calls ast_do_masquerade() on the dead channel
8) bad things happen while doing the masquerade and in the process ast_do_masquerade() puts the dead channel back into the channels container
9) The "orphaned" channel is visible in the channels list if a crash does not happen.
This patch does the following:
1) ast_hangup() sets the zombie flag on a successfully hung-up channel and does not release the channel lock until that has happened.
2) __ast_channel_masquerade() is fixed to not setup a masquerade if either channel is a zombie.
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Replicated the crash in ASTERISK-18222 with PickupChan() and *8 methods.
With the patch, the crash no longer happens and the new message of attempting to masquerade into a dead channel is output.</pre>
</td>
</tr>
</table>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-18222">ASTERISK-18222</a>,
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-18273">ASTERISK-18273</a>
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/branches/1.8/channels/chan_agent.c <span style="color: grey">(333945)</span></li>
<li>/branches/1.8/main/channel.c <span style="color: grey">(333945)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/1400/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>