mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-29 18:19:30 +00:00
Merged revisions 116296 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r116296 | tilghman | 2008-05-14 11:46:48 -0500 (Wed, 14 May 2008) | 2 lines Detect another way for a connection to have gone away. (closes issue #12618) Reported by: ctooley Patches: 1.4-externalivr-test_fd.diff uploaded by ctooley (license 136) trunk-externalivr-test_fd.diff uploaded by ctooley (license 136) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@116298 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -481,6 +481,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
|
|||||||
struct ast_channel *rchan;
|
struct ast_channel *rchan;
|
||||||
char *command;
|
char *command;
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
int test_available_fd = -1;
|
||||||
|
|
||||||
FILE *eivr_commands = NULL;
|
FILE *eivr_commands = NULL;
|
||||||
FILE *eivr_errors = NULL;
|
FILE *eivr_errors = NULL;
|
||||||
@@ -500,6 +501,8 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_available_fd = open("/dev/null", O_RDONLY);
|
||||||
|
|
||||||
setvbuf(eivr_events, NULL, _IONBF, 0);
|
setvbuf(eivr_events, NULL, _IONBF, 0);
|
||||||
setvbuf(eivr_commands, NULL, _IONBF, 0);
|
setvbuf(eivr_commands, NULL, _IONBF, 0);
|
||||||
@@ -574,7 +577,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
|
|||||||
} else if (ready_fd == eivr_commands_fd) {
|
} else if (ready_fd == eivr_commands_fd) {
|
||||||
char input[1024];
|
char input[1024];
|
||||||
|
|
||||||
if (exception || feof(eivr_commands)) {
|
if (exception || (dup2(eivr_commands_fd, test_available_fd) == -1) || feof(eivr_commands)) {
|
||||||
ast_chan_log(LOG_WARNING, chan, "Child process went away\n");
|
ast_chan_log(LOG_WARNING, chan, "Child process went away\n");
|
||||||
res = -1;
|
res = -1;
|
||||||
break;
|
break;
|
||||||
@@ -685,6 +688,10 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
|
if (test_available_fd > -1) {
|
||||||
|
close(test_available_fd);
|
||||||
|
}
|
||||||
|
|
||||||
if (eivr_events)
|
if (eivr_events)
|
||||||
fclose(eivr_events);
|
fclose(eivr_events);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user