[Asterisk-cvs] asterisk/apps app_agi.c,1.13,1.14

martinp at lists.digium.com martinp at lists.digium.com
Wed Nov 5 17:17:22 CST 2003


Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv1389/apps

Modified Files:
	app_agi.c 
Log Message:
Make AGI work when ast_waitfor_nands returns without anything because of EINTR


Index: app_agi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_agi.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- app_agi.c	22 Oct 2003 03:37:47 -0000	1.13
+++ app_agi.c	5 Nov 2003 23:43:31 -0000	1.14
@@ -1218,7 +1218,7 @@
 	}
 	return 0;
 }
-
+#define RETRY	3
 static int run_agi(struct ast_channel *chan, char *request, AGI *agi, int pid)
 {
 	struct ast_channel *c;
@@ -1228,6 +1228,9 @@
 	struct ast_frame *f;
 	char buf[2048];
 	FILE *readf;
+	//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;
+
 	if (!(readf = fdopen(agi->ctrl, "r"))) {
 		ast_log(LOG_WARNING, "Unable to fdopen file descriptor\n");
 		kill(pid, SIGHUP);
@@ -1239,6 +1242,7 @@
 		ms = -1;
 		c = ast_waitfor_nandfds(&chan, 1, &agi->ctrl, 1, NULL, &outfd, &ms);
 		if (c) {
+			retry = RETRY;
 			/* Idle the channel until we get a command */
 			f = ast_read(c);
 			if (!f) {
@@ -1254,6 +1258,7 @@
 				ast_frfree(f);
 			}
 		} else if (outfd > -1) {
+			retry = RETRY;
 			if (!fgets(buf, sizeof(buf), readf)) {
 				/* Program terminated */
 				if (returnstatus)
@@ -1274,9 +1279,11 @@
 				break;
 			}
 		} else {
-			ast_log(LOG_WARNING, "No channel, no fd?\n");
-			returnstatus = -1;
-			break;
+			if (--retry <= 0) {
+				ast_log(LOG_WARNING, "No channel, no fd?\n");
+				returnstatus = -1;
+				break;
+			}
 		}
 	}
 	/* Notify process */




More information about the svn-commits mailing list