From acaf8c9cc96f0d0642c008818232f0d62a08ee7c Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Thu, 1 Dec 2005 23:49:44 +0000 Subject: [PATCH] don't block waiting for the Festival server forever when it goes away (issue #5882) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@7269 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_festival.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/app_festival.c b/apps/app_festival.c index 03753642cc..186a50ae7b 100644 --- a/apps/app_festival.c +++ b/apps/app_festival.c @@ -455,8 +455,20 @@ static int festival_exec(struct ast_channel *chan, void *vdata) /* This assumes only one waveform will come back, also LP is unlikely */ wave = 0; do { + int read_data; for (n=0; n < 3; ) - n += read(fd,ack+n,3-n); + { + read_data = read(fd,ack+n,3-n); + /* this avoids falling in infinite loop + * in case that festival server goes down + * */ + if ( read_data == -1 ) + { + ast_log(LOG_WARNING,"Unable to read from cache/festival fd"); + return -1; + } + n += read_data; + } ack[3] = '\0'; if (strcmp(ack,"WV\n") == 0) { /* receive a waveform */ ast_log(LOG_DEBUG,"Festival WV command\n");