diff options
-rw-r--r-- | main/channel.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/main/channel.c b/main/channel.c index 7983c4216..a41366b1b 100644 --- a/main/channel.c +++ b/main/channel.c @@ -2448,6 +2448,12 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) usleep(1); } + if (chan->fdno == -1) { + ast_log(LOG_ERROR, "ast_read() called with no recorded file descriptor.\n"); + f = &ast_null_frame; + goto done; + } + if (chan->masq) { if (ast_do_masquerade(chan)) ast_log(LOG_WARNING, "Failed to perform masquerade\n"); @@ -2464,6 +2470,12 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) } prestate = chan->_state; + /* + * Reset the recorded file descriptor that triggered this read so that we can + * easily detect when ast_read() is called without properly using ast_waitfor(). + */ + chan->fdno = -1; + /* Read and ignore anything on the alertpipe, but read only one sizeof(blah) per frame that we send from it */ if (chan->alertpipe[0] > -1) { |