From 4f98b05cd55b578fa402d4715ecc188f6d6ed5aa Mon Sep 17 00:00:00 2001 From: Steve Murphy Date: Tue, 14 Aug 2007 13:46:58 +0000 Subject: [PATCH] Don't ask me why, but waitfordigit will immediately return a 1 on my system, unless the outfd is initialized to -1 before calling the nandfds func git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@79378 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_zap.c | 1 + main/channel.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/channels/chan_zap.c b/channels/chan_zap.c index e4304a5569..35be3ecdf8 100644 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -6079,6 +6079,7 @@ static void *ss_thread(void *data) ast_hangup(chan); return NULL; } else if (res) { + ast_debug(1,"waitfordigit returned '%c' (%d), timeout = %d\n", res, res, timeout); exten[len++]=res; exten[len] = '\0'; } diff --git a/main/channel.c b/main/channel.c index 51b5da9b3e..3ddda153cb 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1991,12 +1991,14 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd) if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) return -1; /* Wait for a digit, no more than ms milliseconds total. */ + while (ms) { struct ast_channel *rchan; - int outfd; + int outfd=-1; errno = 0; rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms); + if (!rchan && outfd < 0 && ms) { if (errno == 0 || errno == EINTR) continue; @@ -2004,6 +2006,7 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd) return -1; } else if (outfd > -1) { /* The FD we were watching has something waiting */ + ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n"); return 1; } else if (rchan) { int res;