[asterisk-dev] AST_FRAME_NULL - what is it?
Tilghman Lesher
tilghman at mail.jeffandtilghman.com
Fri May 29 11:42:38 CDT 2009
On Friday 29 May 2009 11:08:59 Moises Silva wrote:
> > That makes sense. Even before I dive in to the code to try to find out
> > *what* is hanging on to the channel lock, is there some coding
> > technique I can apply to my code, to correctly wait for the lock, and/
> > or yield to other threads, before I call ast_read, so that I can be
> > certain I won't get a AST_FRAME_NULL in return?
>
> ast_channel_lock(chan) will block until it can get the lock, so if you
> use that before reading you are certain ast_read will get it as well
> (mutex in Asterisk are recursive). However you have not even confirmed
> that my guess (ast_read not being able to get the lock) is true, first
> I think you should confirm that. If you are developing also be sure to
> compile Asterisk as follows
>
> ./configure --enable-dev-mode
> make menuselect
> -> compiler flags
> -> DONT_OPTIMIZE, DEBUG_CHANNEL_LOCKS, DEBUG_THREADS
>
> then you have cli commands such core show locks, core show threads
> etc, grep those options in Asterisk source code for more info about
> what they do. AFAIR DEBUG_CHANNEL_LOCKS will give you enough info
> about who is holding the lock and where was taken.
One additional caveat -- make sure you aren't holding any locks when you
call ast_channel_lock or you may initiate a deadlock situation.
DEBUG_CHANNEL_LOCKS is NOT what you want; rather, you want DEBUG_THREADS,
as this enables the CLI command "core show locks", which will show you all
locks presently held at a snapshot in time.
--
Tilghman
More information about the asterisk-dev
mailing list