[asterisk-bugs] [Asterisk 0010035]: Agi exits without any possibility to catch on stream file

noreply at bugs.digium.com noreply at bugs.digium.com
Thu Jul 26 23:07:52 CDT 2007


The following issue has been set as RELATED TO issue 0010315. 
====================================================================== 
http://bugs.digium.com/view.php?id=10035 
====================================================================== 
Reported By:                gasparz
Assigned To:                Corydon76
====================================================================== 
Project:                    Asterisk
Issue ID:                   10035
Category:                   Resources/res_agi
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     closed
Asterisk Version:            1.2.16  
SVN Branch (only for SVN checkouts, not tarball releases): N/A  
SVN Revision (number only!):  
Disclaimer on File?:        No 
Request Review:              
Resolution:                 fixed
Fixed in Version:           
====================================================================== 
Date Submitted:             06-22-2007 05:19 CDT
Last Modified:              06-25-2007 13:20 CDT
====================================================================== 
Summary:                    Agi exits without any possibility to catch on stream
file
Description: 
Hi,

When somebody hangs up in the middle of a stream file, the agi script
terminates right away. Setting Sighup handler to SIG_IGN doesn't help.

I think this can be reproduced in all versions of the 1.2 branch (I
checked the code in the 1.4 version and I think it still has the problem).

How to reproduce:

write an agi script like:

<?php
declare(ticks = 1);
    if (function_exists('pcntl_signal')) {
   pcntl_signal(SIGHUP,  SIG_IGN);
    }
include("phpagi.php");
$agi = new AGI();
	$agi->verbose("before stream file",3);
	$agi->stream_file("prepaid-no-enough-credit-stop", "");
	$agi->verbose("after stream file",3);
?>

dialplan:
exten => 10,1,AGI(test.php);

expected result:
In any case of hangup to write the text: "after stream file";

If the call is hung_up before the whole file is played back it exits right
away and in the cli doesn't write the "after stream file".

in res_agi.c 

when it is hanged up prematurly you have -1 in res otherwise 0

00590    if (res >= 0)
00591       return RESULT_SUCCESS;
00592    else
00593       return RESULT_FAILURE;

Fixing the problem is to retun RESULT_SUCCESS; on line 00593 not return
RESULT_FAILURE;

With this it works just fine.

Another thing: 
 res = ast_playstream(fs);
00573    if (res) {
00574       fdprintf(agi->fd, "200 result=%d endpos=%ld\n", res,
sample_offset);
00575       if (res >= 0)
00576          return RESULT_SHOWUSAGE;
00577       else
00578          return RESULT_FAILURE;
00579    }

ast_playstream ALWAYS returns 0 so the whole if is for nothing! 

Same in branch 1.4
00590    res = ast_playstream(fs);
00591    if (vfs)
00592       vres = ast_playstream(vfs);
00593    
00594    if (res) {
00595       fdprintf(agi->fd, "200 result=%d endpos=%ld\n", res,
sample_offset);
00596       return (res >= 0) ? RESULT_SHOWUSAGE : RESULT_FAILURE;
00597    }


======================================================================
Relationships       ID      Summary
----------------------------------------------------------------------
related to          0010315 res_agi behaviour change in 1.2 &amp; 1.4
====================================================================== 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
07-26-07 23:07  juggie         Relationship added       related to 0010315  
======================================================================




More information about the asterisk-bugs mailing list