]> git.ipfire.org Git - thirdparty/asterisk.git/commit
CDR: Alter destruction pattern for CDR chains. 51/4151/1
authorMark Michelson <mmichelson@digium.com>
Tue, 18 Oct 2016 21:30:17 +0000 (16:30 -0500)
committerMark Michelson <mmichelson@digium.com>
Tue, 18 Oct 2016 21:58:02 +0000 (16:58 -0500)
commit012fda29d23bac1d2b06e9a8933980047da30246
treeff00669c5eb7faba990aabcabc58dab4d88c3a3a
parent546ec4b038ac3d750c5138d7fbb8e3ce93f482df
CDR: Alter destruction pattern for CDR chains.

CDRs form chains. When the root of the chain is destroyed, it then
unreferences the next CDR in the chain. That CDR is destroyed, and it
then unreferences the next CDR in the chain. This repeats until the end
of the chain is reached. While this typically does not cause any sort of
problems, it is possible in strange scenarios for the CDR chain to grow
way longer than expected. In such a scenario, the destruction pattern
can result in a stack overflow.

This patch fixes the problem by switching from a recursive pattern to an
iterative pattern for destruction. When the root CDR is destroyed, it is
responsible for iterating over the rest of the CDRs and unreferencing
each one. Other CDRs in the chain, since they are not the root, will
simply destroy themselves and be done. This causes the stack depth not
to increase.

ASTERISK-26421 #close
Reported by Andrew Nagy

Change-Id: I3ca90c2b8051f3b7ead2e0e43f60d2c18fb204b8
main/cdr.c