<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/2002/">https://reviewboard.asterisk.org/r/2002/</a>
     </td>
    </tr>
   </table>
   <br />









<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://reviewboard.asterisk.org/r/2002/diff/1/?file=29143#file29143line1187" style="color: black; font-weight: bold; text-decoration: underline;">/trunk/main/channel.c</a>
    <span style="font-weight: normal;">

     (Diff revision 1)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">struct ast_channel *ast_dummy_channel_alloc(void)</pre></td>

  </tr>
 </tbody>




 
 



 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1187</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="n">ast_pbx_hangup_handler_init</span><span class="p">(</span><span class="n">tmp</span><span class="p">);</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1188</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="n">AST_LIST_HEAD_INIT_NOLOCK</span><span class="p">(</span><span class="n">ast_channel_datastores</span><span class="p">(</span><span class="n">tmp</span><span class="p">));</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1189</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I can&#39;t think of a good reason to manage hangup handlers on dummy channels. I think they should be left off of dummy channels completely if possible.</pre>
</div>
<br />

<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://reviewboard.asterisk.org/r/2002/diff/1/?file=29145#file29145line4692" style="color: black; font-weight: bold; text-decoration: underline;">/trunk/main/features.c</a>
    <span style="font-weight: normal;">

     (Diff revision 1)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">before_you_go:</pre></td>

  </tr>
 </tbody>




 
 



 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">4653</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="k">if</span> <span class="p">(</span><span class="n">ast_pbx_hangup_handler_run</span><span class="p">(</span><span class="n">chan</span><span class="p">))</span> <span class="p">{</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">4654</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                        <span class="cm">/* Indicate hangup handlers were run. */</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">4655</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                        <span class="n">hangup_run</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span></pre></td>
  </tr>

 </tbody>





 
 

 <tbody>

  <tr>
    <th bgcolor="#f0f0f0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">4681</font></th>
    <td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="p">}</span></pre></td>
    <th bgcolor="#f0f0f0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">4656</font></th>
    <td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="p">}</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">You could simplify this to

hangup_run = ast_pbx_hangup_handler_run(chan);</pre>
</div>
<br />



<p>- Mark</p>


<br />
<p>On June 25th, 2012, 11:30 a.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 and kobaz.</div>
<div>By rmudgett.</div>


<p style="color: grey;"><i>Updated June 25, 2012, 11:30 a.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 feature originated with https://reviewboard.asterisk.org/r/1230/ by kobaz.

See
https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Projects
https://wiki.asterisk.org/wiki/display/AST/Hangup+handlers

Hangup handlers are an alternative to the h extension.  They can be used 
in addition to the h extension.  The idea is to attach a Gosub routine to 
a channel that will execute when the call hangs up.  Whereas which h 
extension gets executed depends on the location of dialplan execution when 
the call hangs up, hangup handlers are attached to the call channel.  You 
can attach multiple handlers that will execute in the order of most 
recently added first.  

Call transfers, call pickup, and call parking can result in channels on 
both sides of a bridge containing hangup handlers.  

Hangup handlers can also be attached to any call leg because of pre-dial 
routines.  


When hangup handlers are executed

Any hangup handlers associated with a channel are always executed when the 
channel is hung up.  


Manipulating hangup handlers on a channel

Hangup handlers pass the saved handler string to the Gosub application to 
execute.  The syntax is intentionally the same as the Gosub application.  
If context or exten are not supplied then the current values from the 
channel pushing the hangup handler are inserted before storing on the 
hangup handler stack.  

Push a hangup handler onto a channel:
same =&gt; n,Set(CHANNEL(hangup_handler_push)=[[context,]exten,]priority[(arg1[,...][,argN])]);

Pop a hangup handler off a channel and optionally push a replacement:
same =&gt; n,Set(CHANNEL(hangup_handler_pop)=[[[context,]exten,]priority[(arg1[,...][,argN])]]);

Pop all hangup handlers off a channel and optionally push a replacement:
same =&gt; n,Set(CHANNEL(hangup_handler_replace)=[[[context,]exten,]priority[(arg1[,...][,argN])]]);

Cascading hangup handlers
same =&gt; n,Set(CHANNEL(hangup_handler_push)=hdlr3,s,1(args));
same =&gt; n,Set(CHANNEL(hangup_handler_push)=hdlr2,s,1(args));
same =&gt; n,Set(CHANNEL(hangup_handler_push)=hdlr1,s,1(args));


AMI events

The hangup handler AMI events are output as part of the AMI dialplan 
permission class.  

* The AMI event HangupHandlerPush is generated whenever a hangup handler 
is pushed on the stack by the CHANNEL() function.  

* The AMI event HangupHandlerPop is generated whenever a hangup handler is 
popped off the stack by the CHANNEL() function.  

* The AMI event HangupHandlerRun is generated as a hangup handler is about 
to be executed.  


CLI commands

Single channel:
core show hanguphandlers &lt;chan&gt;

Output:
Channel       Handler
&lt;chan-name&gt;   &lt;first handler to execute&gt;
              &lt;second handler to execute&gt;
              &lt;third handler to execute&gt;

All channels:
core show hanguphandlers all

Output:
Channel       Handler
&lt;chan1-name&gt;  &lt;first handler to execute&gt;
              &lt;second handler to execute&gt;
              &lt;third handler to execute&gt;
&lt;chan2-name&gt;  &lt;first handler to execute&gt;
&lt;chan3-name&gt;  &lt;first handler to execute&gt;
              &lt;second handler to execute&gt;
</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;">Attached hangup handlers to channels and done the following kinds of calls:
Simple A to B call.
DTMF attended transfer
DTMF blind transfer

Hangup handlers were executed when expected.</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/.cleancount <span style="color: grey">(369297)</span></li>

 <li>/trunk/apps/app_dial.c <span style="color: grey">(369297)</span></li>

 <li>/trunk/apps/app_followme.c <span style="color: grey">(369297)</span></li>

 <li>/trunk/apps/app_queue.c <span style="color: grey">(369297)</span></li>

 <li>/trunk/channels/chan_local.c <span style="color: grey">(369297)</span></li>

 <li>/trunk/configs/cdr.conf.sample <span style="color: grey">(369297)</span></li>

 <li>/trunk/funcs/func_channel.c <span style="color: grey">(369297)</span></li>

 <li>/trunk/include/asterisk/channel.h <span style="color: grey">(369297)</span></li>

 <li>/trunk/include/asterisk/pbx.h <span style="color: grey">(369297)</span></li>

 <li>/trunk/main/autoservice.c <span style="color: grey">(369297)</span></li>

 <li>/trunk/main/channel.c <span style="color: grey">(369297)</span></li>

 <li>/trunk/main/channel_internal_api.c <span style="color: grey">(369297)</span></li>

 <li>/trunk/main/features.c <span style="color: grey">(369297)</span></li>

 <li>/trunk/main/pbx.c <span style="color: grey">(369297)</span></li>

</ul>

<p><a href="https://reviewboard.asterisk.org/r/2002/diff/" style="margin-left: 3em;">View Diff</a></p>




  </td>
 </tr>
</table>








  </div>
 </body>
</html>