Subject: | [patch] HANGUP AGI message can cause get_variable to come back empty |
Summary: by default Asterisk will send a fastagi script the HANGUP
message when the call ends. If this message arrives and the next thing
you wish to do is get a variable using ASTERISK::AGI it will fail due to
this HANGUP command being in the read buffer.
One working fix is attached. Another might be to flush the buffer when
doing the get variable but there is a small chance the HANGUP can still
creep in there.
This is a nasty little bug due to another nasty little bug in asterisk
where as the the HANGUP does not show up on the console doing a set agi
debug on, although all other messages do.
Reference:
https://wiki.asterisk.org/wiki/display/AST/Application_AGI
Subject: | AGI.pm.diff |
--- AGI.pm.orig 2011-10-14 11:47:14.219314357 -0500
+++ AGI.pm 2011-10-14 11:51:35.539314451 -0500
@@ -161,8 +161,8 @@
print STDERR " -- $1 = $2\n";
}
$self->_addenv($1, $2);
- } elsif ($readvars && $response eq '') {
- print STDERR "Skipping blank response because we just read vars\n" if ($self->_debug > 0);
+ } elsif (($readvars && ($response eq '')) || ($response eq 'HANGUP')) {
+ print STDERR "Skipping blank response or HANGUP because we just read vars\n" if ($self->_debug > 0);
$readvars = 0;
} elsif ($response) {
return($response);