Index: res/res_agi.c
===================================================================
--- res/res_agi.c (revision 30337)
+++ res/res_agi.c (working copy)
@@ -1799,6 +1799,7 @@
/* how many times we'll retry if ast_waitfor_nandfs will return without either
channel or file descriptor in case select is interrupted by a system call (EINTR) */
int retry = RETRY;
+ int changone = 0;
if (!(readf = fdopen(agi->ctrl, "r"))) {
ast_log(LOG_WARNING, "Unable to fdopen file descriptor\n");
@@ -1811,7 +1812,7 @@
setup_env(chan, request, agi->fd, (agi->audio > -1));
for (;;) {
ms = -1;
- c = ast_waitfor_nandfds(&chan, dead ? 0 : 1, &agi->ctrl, 1, NULL, &outfd, &ms);
+ c = ast_waitfor_nandfds(&chan, changone ? 0 : 1, &agi->ctrl, 1, NULL, &outfd, &ms);
if (c) {
retry = RETRY;
/* Idle the channel until we get a command */
@@ -1819,7 +1820,10 @@
if (!f) {
ast_log(LOG_DEBUG, "%s hungup\n", chan->name);
returnstatus = AGI_RESULT_HANGUP;
- break;
+ if (dead)
+ changone = 1;
+ else
+ break;
} else {
/* If it's voice, write it to the audio pipe */
if ((agi->audio > -1) && (f->frametype == AST_FRAME_VOICE)) {