<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/1230/">https://reviewboard.asterisk.org/r/1230/</a>
</td>
</tr>
</table>
<br />
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This review should be discarded in favor of https://reviewboard.asterisk.org/r/2002/</pre>
<br />
<p>- rmudgett</p>
<br />
<p>On March 16th, 2012, 6:54 p.m., kobaz 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.</div>
<div>By kobaz.</div>
<p style="color: grey;"><i>Updated March 16, 2012, 6:54 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;">This is the hangup handler patch, and associated
helper function ast_pbx_exten_parse(), which I think is needed to
separate the functionality of parsing a gosub target from actually going
to the target. It's been malloc debugged and valgrind debugged and tested
for several months in production environments.
Overview of module:
I find the 'h' extensions to be limited, cumbersome, and error prone
when writing very complex dialplan, especially when using lots of gotos
and gosubs. Say you have a main dialplan entry point context called
callqueue. If at any point after callqueue runs, you want to run a
hangup handler specific for the callqueue dialplan, you have to put an
'h' extension in every single context you plan to possibly jump to after
entering callqueue. This solves that problem, and gives the added
benefit of cascading hangup handlers.
For proof of concept development convenience, I used an existing
function for setting up the hangup handlers, but it should probably be
it's own function
Cascading hangup handlers are also possible, where as with standard
dialplan h extensions, they are not:
context test {
s => {
goto fooTest, s, 1;
}
}
context fooTest {
s => {
GoSub(barTest,s,1);
}
h => {
NoOp(footest hangup);
}
}
context barTest {
s => {
NoOp(something in bar);
Hangup();
}
h => {
NoOp(bartest hangup);
}
}
Execution:
-- Goto (fooTest,s,1)
-- Executing [s at fooTest:1] Gosub("SIP/tipton-local-0000000b",
"barTest,s,1") in new stack
-- Executing [s at barTest:1] NoOp("SIP/tipton-local-0000000b",
"something in bar") in new stack
-- Executing [s at barTest:2] Hangup("SIP/tipton-local-0000000b", "")
in new stack
== Spawn extension (barTest, s, 2) exited non-zero on
'SIP/intellasoft-tipton-local-0000000b'
-- Executing [h at barTest:1] NoOp("SIP/tipton-local-0000000b",
"bartest hangup") in new stack
Only the deepest 'h' exten will execute
Where as with this new method, you could call addhanguphandler as many
times as you like, and they will all execute in the order of most
recently added will execute first.
Cascading hangup handlers:
Set(CHANNEL(addhanguphandler)="callqueueHangupHandler,s,1");
Set(CHANNEL(addhanguphandler)="someotherHangupHandler,s,1");
Set(CHANNEL(addhanguphandler)="yetanotherHangupHandler,s,1");
**NOTE**: I have had nasty deadlock problems (as you can see a bunch of locking is commented out, but it works nonetheless (scary))
Maybe someone can help me with the locking.</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;">Usage:
context callqueueHangupHandler {
s => {
// cleanup here
}
}
context callqueue {
s => {
Set(CHANNEL(addhanguphandler)="callqueueHangupHandler,s,1");
gosub(foo...)
goto bar..;
}
}
Execution:
1. callqueue: set(channel(addhanguphandler...)
2. gosub
3. goto bar
4. channel hangs up
5. channel launches dialplan @callqueueHangupHandler
</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-19549">ASTERISK-19549</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>trunk/funcs/func_channel.c <span style="color: grey">(320708)</span></li>
<li>trunk/include/asterisk/channel.h <span style="color: grey">(320708)</span></li>
<li>trunk/include/asterisk/pbx.h <span style="color: grey">(320708)</span></li>
<li>trunk/main/channel.c <span style="color: grey">(320708)</span></li>
<li>trunk/main/cli.c <span style="color: grey">(320708)</span></li>
<li>trunk/main/pbx.c <span style="color: grey">(320708)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/1230/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>