--- asterisk-1.6.1.10/apps/app_externalivr.c 2009-11-05 17:10:06.000000000 +0000 +++ /usr/src/redhat/SOURCES/asterisk-1.6.1.10/apps/app_externalivr.c 2009-11-23 18:45:04.000000000 +0000 @@ -107,7 +107,7 @@ }; static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u, - int eivr_events_fd, int eivr_commands_fd, int eivr_errors_fd, + int *eivr_events_fd, int *eivr_commands_fd, int *eivr_errors_fd, const struct ast_str *args, const struct ast_flags flags); int eivr_connect_socket(struct ast_channel *chan, const char *host, int port); @@ -441,7 +441,12 @@ if (!(ser = ast_tcptls_client_create(&ivr_desc)) || !(ser = ast_tcptls_client_start(ser))) { goto exit; } - res = eivr_comm(chan, u, ser->fd, ser->fd, -1, pipe_delim_args, flags); + + child_stdin[1] = ser->fd; + child_stdout[0] = ser->fd; + child_stderr[0] = -1; + + res = eivr_comm(chan, u, &child_stdin[1], &child_stdout[0], &child_stderr[0], pipe_delim_args, flags); } else { @@ -484,7 +489,7 @@ child_stdout[1] = 0; close(child_stderr[1]); child_stderr[1] = 0; - res = eivr_comm(chan, u, child_stdin[1], child_stdout[0], child_stderr[0], pipe_delim_args, flags); + res = eivr_comm(chan, u, &child_stdin[1], &child_stdout[0], &child_stderr[0], pipe_delim_args, flags); } } @@ -519,7 +524,7 @@ } static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u, - int eivr_events_fd, int eivr_commands_fd, int eivr_errors_fd, + int *eivr_events_fd, int *eivr_commands_fd, int *eivr_errors_fd, const struct ast_str *args, const struct ast_flags flags) { struct playlist_entry *entry; @@ -527,7 +532,7 @@ int ms; int exception; int ready_fd; - int waitfds[2] = { eivr_commands_fd, eivr_errors_fd }; + int waitfds[2] = { *eivr_commands_fd, *eivr_errors_fd }; struct ast_channel *rchan; char *command; int res = -1; @@ -538,16 +543,16 @@ FILE *eivr_errors = NULL; FILE *eivr_events = NULL; - if (!(eivr_events = fdopen(eivr_events_fd, "w"))) { + if (!(eivr_events = fdopen(*eivr_events_fd, "w"))) { ast_chan_log(LOG_WARNING, chan, "Could not open stream to send events\n"); goto exit; } - if (!(eivr_commands = fdopen(eivr_commands_fd, "r"))) { + if (!(eivr_commands = fdopen(*eivr_commands_fd, "r"))) { ast_chan_log(LOG_WARNING, chan, "Could not open stream to receive commands\n"); goto exit; } - if (eivr_errors_fd > -1) { /* if opening a socket connection, error stream will not be used */ - if (!(eivr_errors = fdopen(eivr_errors_fd, "r"))) { + if (*eivr_errors_fd > -1) { /* if opening a socket connection, error stream will not be used */ + if (!(eivr_errors = fdopen(*eivr_errors_fd, "r"))) { ast_chan_log(LOG_WARNING, chan, "Could not open stream to receive errors\n"); goto exit; } @@ -632,10 +637,10 @@ break; } ast_frfree(f); - } else if (ready_fd == eivr_commands_fd) { + } else if (ready_fd == *eivr_commands_fd) { char input[1024]; - if (exception || (dup2(eivr_commands_fd, test_available_fd) == -1) || 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"); res = -1; break; @@ -754,7 +759,7 @@ else ast_chan_log(LOG_WARNING, chan, "Unknown option requested '%s'\n", &input[2]); } - } else if (eivr_errors_fd && ready_fd == eivr_errors_fd) { + } else if (*eivr_errors_fd && ready_fd == *eivr_errors_fd) { char input[1024]; if (exception || feof(eivr_errors)) { @@ -782,15 +787,20 @@ close(test_available_fd); } - if (eivr_events) + if (eivr_events) { fclose(eivr_events); + *eivr_events_fd = 0; + } - if (eivr_commands) + if (eivr_commands) { fclose(eivr_commands); + *eivr_commands_fd = 0; + } - if (eivr_errors) + if (eivr_errors) { fclose(eivr_errors); - + *eivr_errors_fd = 0; + } return res; }