[asterisk-commits] tilghman: branch 1.4 r116296 - /branches/1.4/apps/app_externalivr.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 14 11:46:49 CDT 2008


Author: tilghman
Date: Wed May 14 11:46:48 2008
New Revision: 116296

URL: http://svn.digium.com/view/asterisk?view=rev&rev=116296
Log:
Detect another way for a connection to have gone away.

Modified:
    branches/1.4/apps/app_externalivr.c

Modified: branches/1.4/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_externalivr.c?view=diff&rev=116296&r1=116295&r2=116296
==============================================================================
--- branches/1.4/apps/app_externalivr.c (original)
+++ branches/1.4/apps/app_externalivr.c Wed May 14 11:46:48 2008
@@ -249,6 +249,7 @@
 	int child_stdout[2] = { 0,0 };
 	int child_stderr[2] = { 0,0 };
 	int res = -1;
+	int test_available_fd = -1;
 	int gen_active = 0;
 	int pid;
 	char *argv[32];
@@ -366,6 +367,8 @@
 			ast_chan_log(LOG_WARNING, chan, "Could not open stream for child errors\n");
 			goto exit;
 		}
+
+		test_available_fd = open("/dev/null", O_RDONLY);
 
 		setvbuf(child_events, NULL, _IONBF, 0);
 		setvbuf(child_commands, NULL, _IONBF, 0);
@@ -500,7 +503,7 @@
 			} else if (ready_fd == child_errors_fd) {
 				char input[1024];
 
-				if (exception || feof(child_errors)) {
+				if (exception || (dup2(child_commands_fd, test_available_fd) == -1) || feof(child_errors)) {
 					ast_chan_log(LOG_WARNING, chan, "Child process went away\n");
 					res = -1;
 					break;
@@ -533,6 +536,10 @@
 	if (child_errors)
 		fclose(child_errors);
 
+	if (test_available_fd > -1) {
+		close(test_available_fd);
+	}
+
 	if (child_stdin[0])
 		close(child_stdin[0]);
 




More information about the asterisk-commits mailing list