aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-03 13:55:34 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-03 13:55:34 +0000
commitf19dbc7219974883cb34117c5c720578dd1e755e (patch)
tree60dea461e60402344e3a0eb29b2b055243fefb0b /main
parentb5a569a1225c44473e84223aa84f66b6fe19f4a8 (diff)
Merged revisions 179609 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r179609 | russell | 2009-03-03 07:54:41 -0600 (Tue, 03 Mar 2009) | 17 lines Merged revisions 179608 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r179608 | russell | 2009-03-03 07:53:52 -0600 (Tue, 03 Mar 2009) | 9 lines Make it easier to detect an improper call to ast_read(). When you call ast_waitfor() on a channel, the index into the channel fds array that holds the file descriptor that poll() determines has input available is stored in fdno. This patch clears out this value after a call to ast_read() and also reports errors if ast_read() is called without an fdno set. From a discussion on the asterisk-dev list. ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@179610 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/channel.c12
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) {