Jan,

I'll add something similar to your stream_file patch. Are there any other places that anyone has noticed strange behavior when the user throws invalid data at it?

I really don't like the idea of hangup_aware, but I'm not opposed to adding it as long as it doesn't become the default. I am curious about what you have it printing though. It looks like when it catches a signal (assuming its SIGHUP) it will print "Line hangup got SIG'.HUP.'" I'm not sure if it was your intention to have the be ".$_." instead of '.$_.'

James

Jan Kratochvil wrote:
Hi,

what about the two attached patches?

They were both in use, no one complained here although they never got committed
to the mainline.

Regards,
Jan


On Wed, 27 Sep 2006 22:15:58 +0200, James Golovich wrote:
After far too much time has passed. asterisk-perl version 0.09 has been released. You can currently get it from http://asterisk.gnuinter.net and assuming I don't hear of any major problems in the next day or so I will push it out to CPAN.

James Golovich <[EMAIL PROTECTED]>

-------------------------------------------------------------
0.09    Test release.  Will go to 1.0 shortly after testing
Change AGI.pm so we run ReadParse if the user forgot to run it manually
       Add LICENSE file to source
       Added 2 basic tests of AGI.pm so 'make test' does something
       Time to 'use strict' and 'use warnings' in AGI.pm (Hurray!)
       Added 'SetVar' as available keyword in Outgoing.pm
       Modified Asterisk::AGI set_variable to always quote the value
       Add directory.agi example from C. de Souza <m.list at yahoo.de>
Updated calleridnamelookup.agi from Jeff Siddall <jeff at siddall.name>
       Manager.pm update from Brian Evans <brian at indosoft.ca>
       Patches from Peter Beckman <beckman at purplecow.com> (THANKS!!!)
               Add documentation for missing functions in AGI.pm
               Add control_stream_file to AGI.pm
               Add get_full_variable to AGI.pm
               Add get_option to AGI.pm
               Add say_alpha/date/time/datetime/phonetic to AGI.pm
Change callback to be in central location rather than per function Allow using multiple SetVar in Outgoing.pm from Dariusz Dwornikowski <d.
dwornikowski at proadmin.com.pl>
       Use 'use strict' and 'use warnings' in Outgoing.pm


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------

Subject:
[patch] &stream_file $digits eq ""
From:
Jan Kratochvil <[EMAIL PROTECTED]>
Date:
Sat, 28 Aug 2004 09:49:44 +0200
To:
[email protected]

To:
[email protected]


Hi,

Attached patch handles the case I was using
        $AGI->stream_file($filename,"");

which crashes Asterisk/Asterisk::AGI as it expects either
        $AGI->stream_file($filename);
or:
        $AGI->stream_file($filename,undef());

It would be also nice to document somewhere that Asterisk::AGI functions return
undef() in a communication failure with Asterisk (such as due to the bug
above).


Thanks,
Lace

------------------------------------------------------------------------

--- Asterisk/AGI.pm-orig        Thu Aug  7 20:04:01 2003
+++ Asterisk/AGI.pm     Sat Aug 28 09:45:13 2004
@@ -180,7 +180,7 @@
my $ret = 0; - $digits = '""' if (!defined($digits));
+       $digits = '""' if (!defined($digits) || $digits!~/\S/);
return -1 if (!defined($filename));
        $ret =  $self->execute("STREAM FILE $filename $digits");

------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

------------------------------------------------------------------------

Subject:
Re: Asterisk::AGI does not properly GET DATA
From:
Jan Kratochvil <[EMAIL PROTECTED]>
Date:
Mon, 22 Nov 2004 19:57:41 +0100
To:
Brian Wilkins <[EMAIL PROTECTED]>

To:
Brian Wilkins <[EMAIL PROTECTED]>
CC:
[email protected]


Hi,

The last patch was broken (untested...), fixed, sorry.


Lace
------------------------------------------------------------------------

--- Asterisk/AGI.pm-orig        2003-08-07 20:04:01.000000000 +0200
+++ Asterisk/AGI.pm     2004-11-22 19:49:41.402891515 +0100
@@ -190,6 +190,40 @@
        return $ret;
 }
+=item $AGI->hangup_aware()
+
+Prevent automatic termination of the AGI script on the line hangup.
+You should call this function if you need to take care of special cleanup
+functions _after_ the line has been hungup.
+
+You must carefully check all the returns codes to terminate properly on
+returned -1 (line hangup) values, otherwise a lot of stale processes remain on
+your system running.
+
+WARNING: Modifies Perl $SIG{"HUP"} and $SIG{"PIPE"} handlers!
+
+Example:
+    $AGI->hangup_aware();
+    if (-1==$AGI->stream_file("playme")) {
+        print LOGFILE "Finished after ".(time()-$timestamp_start)." seconds\n";
+       exit 0;
+    }
+
+Returns: 0 as the success.
+
+=cut
+
+sub hangup_aware {
+       my ($self) = @_;
+
+       # We will really get SIGHUP on the line hangup.
+       for (qw(HUP PIPE)) {
+               $SIG{$_}=eval 'sub { warn "Line hangup - got SIG'.$_.'\n"; };';
+       }
+
+       return 0;
+}
+
 =item $AGI->send_text($text)
Executes AGI Command "SEND TEXT "$text"

------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to