From: Russell Bryant Date: Mon, 20 Jul 2009 16:26:24 +0000 (+0000) Subject: Only do the chan->fdno check in ast_read() in a developer build. X-Git-Tag: 1.4.26.2~4^2~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b67a333696e8443b6101714d793029721b8c5fe;p=thirdparty%2Fasterisk.git Only do the chan->fdno check in ast_read() in a developer build. I changed this check to only happen in a dev-mode build. I also added a comment explaining what is going on. I also made it so that detection of this situation does not affect ast_read() operation. (closes issue #14723) Reported by: seadweller git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@207360 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/channel.c b/main/channel.c index 67aa766364..f548d0e6b0 100644 --- a/main/channel.c +++ b/main/channel.c @@ -2080,17 +2080,20 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) goto done; } - if (chan->fdno == -1) { #ifdef AST_DEVMODE + /* + * The ast_waitfor() code records which of the channel's file descriptors reported that + * data is available. In theory, ast_read() should only be called after ast_waitfor() + * reports that a channel has data available for reading. However, there still may be + * some edge cases throughout the code where ast_read() is called improperly. This can + * potentially cause problems, so if this is a developer build, make a lot of noise if + * this happens so that it can be addressed. + */ + if (chan->fdno == -1) { ast_log(LOG_ERROR, "ast_read() called with no recorded file descriptor.\n"); -#else - if (option_debug > 1) { - ast_log(LOG_DEBUG, "ast_read() called with no recorded file descriptor.\n"); - } -#endif - f = &ast_null_frame; - goto done; } +#endif + prestate = chan->_state; /* Read and ignore anything on the alertpipe, but read only