Commit a fix for some memory access errors pointed out by the valgrind2.txt
commitc1bce7f15e4e6ccefaf755495957eb673208dd14
authorrussell <russell@614ede4d-c843-0410-af14-a771ab80d22e>
Tue, 15 Jan 2008 23:26:52 +0000 (15 23:26 +0000)
committerrussell <russell@614ede4d-c843-0410-af14-a771ab80d22e>
Tue, 15 Jan 2008 23:26:52 +0000 (15 23:26 +0000)
tree698e81f4d354cd447cb6b6f592f3b2ae0aa46789
parent113e2695c3d0d6067cd913105bf13f75ee08b193
Commit a fix for some memory access errors pointed out by the valgrind2.txt
output on issue #11698.

The issue here is that it is possible for an instance of a translator to get
destroyed while the frame allocated as a part of the translator is still being
processed.  Specifically, this is possible anywhere between a call to ast_read()
and ast_frame_free(), which is _a lot_ of places in the code.  The reason this
happens is that the channel might get masqueraded during this time.  During a
masquerade, existing translation paths get destroyed.

So, this patch fixes the issue in an API and ABI compatible way.  (This one is
 for you, paravoid!)

It changes an int in ast_frame to be used as flag bits.  The 1 bit is still used
to indicate that the frame contains timing information.  Also, a second flag has
been added to indicate that the frame came from a translator.  When a frame with
this flag gets released and has this flag, a function is called in translate.c to
let it know that this frame is doing being processed.  At this point, the flag gets
cleared.  Also, if the translator was requested to be destroyed while its internal
frame still had this flag set, its destruction has been deffered until it finds out
that the frame is no longer being processed.

Admittedly, this feels like a hack.  But, it does fix the issue, and I was not able
to think of a better solution ...

git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@98943 614ede4d-c843-0410-af14-a771ab80d22e
channels/chan_iax2.c
codecs/codec_zap.c
include/asterisk/frame.h
include/asterisk/translate.h
main/abstract_jb.c
main/frame.c
main/rtp.c
main/translate.c