[asterisk-dev] ast_read and frames of type AST_FRAME_NULL?

Bryan Field-Elliot bryan+asterisk-dev at nextalarm.com
Tue Jun 22 17:58:00 CDT 2010

We have a custom app (for Asterisk which needs to wait for certain events on a SIP channel. 

Our code, briefly, looks like the following:

for (;;) {
	r = ast_waitfor(chan, 100)
	if (r < 0) break;
	frame = ast_read(chan);
	if (frame->frametype == AST_FRAME_NULL) {

What we are finding is that under normal load, we get hundreds of AST_FRAME_NULL's out of ast_read, and it would be in the hundreds of thousands if not for the usleep() command to yield some cycles to other threads.

My question for the group is -- what are we doing wrong? It seems like lots of CPU cycles are being wasted here, creating and then discarding AST_FRAME_NULL's. Do they serve a hidden purpose? If not, is there something else we can do to have ast_waitfor and ast_read truly only return when they have some interesting data to tell us about?

Thank you,


More information about the asterisk-dev mailing list