]> git.ipfire.org Git - thirdparty/asterisk.git/commit
CDR: Alter destruction pattern for CDR chains. 52/4152/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 22:14:38 +0000 (17:14 -0500)
commit0abc71dfd69d7a649460435da7ea72c00daea120
treed001e93e90960cb46421064a41ff070052fb3233
parentab030fcc1fe0a7dfd4c435feb7f36a94b12e4e32
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